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
This commit is contained in:
Benjamin
2025-10-26 13:57:06 +01:00
parent 2410653f63
commit 8ca23ce736

View File

@@ -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