Add streaming, subscribe, cancel cleanup, and recovery component tests

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Alexander
2026-05-11 15:54:25 +02:00
parent be859e87c0
commit 93821ab214
5 changed files with 1375 additions and 1 deletions
+23
View File
@@ -48,6 +48,10 @@ func setupSuite(t *testing.T) *testSuite {
schemaSQL, err := os.ReadFile(schemaPath)
require.NoError(t, err, "failed to read schema file")
migrationPath := getMigrationPath(t, "003_event_bus.sql")
migrationSQL, err := os.ReadFile(migrationPath)
require.NoError(t, err, "failed to read migration file")
pgContainer, err := postgres.Run(ctx,
"postgres:16-alpine",
postgres.WithDatabase("music_agregator_test"),
@@ -81,6 +85,9 @@ func setupSuite(t *testing.T) *testSuite {
_, err = pool.Exec(ctx, string(schemaSQL))
require.NoError(t, err, "failed to apply schema")
_, err = pool.Exec(ctx, string(migrationSQL))
require.NoError(t, err, "failed to apply migration")
db := &database.DB{Pool: pool}
mocks := &testMocks{
@@ -156,10 +163,26 @@ func getSchemaPath(t *testing.T) string {
return schemaPath
}
func getMigrationPath(t *testing.T, filename string) string {
_, currentFile, _, ok := runtime.Caller(0)
require.True(t, ok, "failed to get current file path")
testDir := filepath.Dir(currentFile)
migrationPath := filepath.Join(testDir, "..", "..", "..", "containers", "database", "music-agregator", filename)
if _, err := os.Stat(migrationPath); os.IsNotExist(err) {
migrationPath = filepath.Join(testDir, "..", "..", "containers", "database", "music-agregator", filename)
}
return migrationPath
}
func cleanTables(t *testing.T, pool *pgxpool.Pool) {
ctx := context.Background()
tables := []string{
"album_events",
"workflow_runs",
"download_files",
"downloads",
"torrents",