Add test coverage to prevent issues like #241 in the future (#244)

* Add test coverage to prevent issues like #241 in the future

* Add debugging

* Fix location of HISHTORY_COMPOSE_TEST var

* Enable tmate for failures

* update

* Re-comment tmate
This commit is contained in:
David Dworken
2024-09-06 17:08:08 -07:00
committed by GitHub
parent a987801854
commit 11fc92ee5f
3 changed files with 20 additions and 3 deletions

View File

@@ -97,7 +97,19 @@ func OpenDB() (*database.DB, error) {
}
err = db.CreateIndices()
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to create indices: %w", err)
}
}
if os.Getenv("HISHTORY_COMPOSE_TEST") != "" {
// Run an extra round of migrations to test the migration code path to prevent issues like #241
fmt.Println("AutoMigrating DB tables a second time for test coverage")
err := db.AddDatabaseTables()
if err != nil {
return nil, fmt.Errorf("failed to create underlying DB tables: %w", err)
}
err = db.CreateIndices()
if err != nil {
return nil, fmt.Errorf("failed to create indices: %w", err)
}
}
return db, nil