feat(10-02): add migration 6 integration tests and NewTestDBWithLibrary helper
- Add NewTestDBWithLibrary helper for tests needing a pre-created library - TestMigration6FreshDB: verify all tables, columns, phantom cols, VIEW, and user_version - TestMigration6LibraryQueries: verify CRUD operations and unique path constraint - TestMigration6PhantomPlaylistTracks: verify SET NULL FK preserves phantom metadata - TestMigration6AudioFilesLibraryFK: verify FK enforcement on library_id - TestMigration6TrackMetadataViewHasLibraryID: verify VIEW includes library_id
This commit is contained in:
@@ -81,3 +81,27 @@ func NewTestDB(t *testing.T) *DB {
|
||||
logger: slog.Default(),
|
||||
}
|
||||
}
|
||||
|
||||
// NewTestDBWithLibrary returns a test DB with a library row
|
||||
// pre-inserted. Returns the DB and the library ID.
|
||||
func NewTestDBWithLibrary(
|
||||
t *testing.T,
|
||||
name, libPath string,
|
||||
) (*DB, int64) {
|
||||
t.Helper()
|
||||
|
||||
db := NewTestDB(t)
|
||||
|
||||
lib, err := db.Queries.CreateLibrary(
|
||||
db.Ctx,
|
||||
sqlcgen.CreateLibraryParams{
|
||||
Name: name,
|
||||
Path: libPath,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("could not create test library: %v", err)
|
||||
}
|
||||
|
||||
return db, lib.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user