From 8ca23ce736df7beec067cd084360b18771d5ca77 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sun, 26 Oct 2025 13:57:06 +0100 Subject: [PATCH] fix: ensure migrations directory is found in CI tests - Fix migration path lookup to check both './migrations' and './backend/migrations' - Remove hardcoded test schema in admin handler tests - Use database.SetupTestDB which applies all migrations automatically - Ensures test schema matches production schema with all columns (deleted_at, doc_checksum, etc.) - Fixes test failures in CI where admin handler tests returned empty responses --- backend/internal/infrastructure/database/testutils.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/internal/infrastructure/database/testutils.go b/backend/internal/infrastructure/database/testutils.go index d2a71ce..6803cc6 100644 --- a/backend/internal/infrastructure/database/testutils.go +++ b/backend/internal/infrastructure/database/testutils.go @@ -121,19 +121,20 @@ func (tdb *TestDB) createSchema() error { return fmt.Errorf("failed to get working directory: %w", err) } - // Walk up the directory tree looking for backend/migrations + // Walk up the directory tree looking for migrations directory found := false searchDir := wd for i := 0; i < 10; i++ { - testPath := filepath.Join(searchDir, "backend", "migrations") + // Try migrations in current directory + testPath := filepath.Join(searchDir, "migrations") if stat, err := os.Stat(testPath); err == nil && stat.IsDir() { migrationsPath = testPath found = true break } - // Also try just "migrations" directory - testPath = filepath.Join(searchDir, "migrations") + // Try backend/migrations (for root project directory) + testPath = filepath.Join(searchDir, "backend", "migrations") if stat, err := os.Stat(testPath); err == nil && stat.IsDir() { migrationsPath = testPath found = true