feat: complete Task 1 - update database schema and model for live/remix filtering
This commit is contained in:
@@ -31,7 +31,7 @@ func TestNew_InitializationAndSchema(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestNew_MigrationIdempency verifies that calling New() twice (via migrate) does not fail.
|
||||
// TestNew_MigrationIdempotency verifies that calling New() twice (via migrate) does not fail.
|
||||
func TestNew_MigrationIdempotency(t *testing.T) {
|
||||
db, err := New(":memory:")
|
||||
if err != nil {
|
||||
@@ -89,26 +89,27 @@ func TestArtistSettingsSchema(t *testing.T) {
|
||||
|
||||
// Insert a row to verify column names and types.
|
||||
_, err = db.Conn().Exec(
|
||||
"INSERT INTO artist_settings (id, name, ignore_singles, ignore_compilations, monitored) VALUES (?, ?, ?, ?, ?)",
|
||||
"artist-1", "Test Artist", true, false, true,
|
||||
"INSERT INTO artist_settings (id, name, ignore_singles, ignore_compilations, ignore_live, ignore_remix, monitored) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
"artist-1", "Test Artist", true, false, false, false, true,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("insert into artist_settings: %v", err)
|
||||
}
|
||||
|
||||
var id, name string
|
||||
var ignoreLive, ignoreRemix bool
|
||||
var ignoreSingles, ignoreCompilations, monitored bool
|
||||
err = db.Conn().QueryRow(
|
||||
"SELECT id, name, ignore_singles, ignore_compilations, monitored FROM artist_settings WHERE id = ?",
|
||||
"SELECT id, name, ignore_singles, ignore_compilations, ignore_live, ignore_remix, monitored FROM artist_settings WHERE id = ?",
|
||||
"artist-1",
|
||||
).Scan(&id, &name, &ignoreSingles, &ignoreCompilations, &monitored)
|
||||
).Scan(&id, &name, &ignoreSingles, &ignoreCompilations, &ignoreLive, &ignoreRemix, &monitored)
|
||||
if err != nil {
|
||||
t.Fatalf("select from artist_settings: %v", err)
|
||||
}
|
||||
|
||||
if id != "artist-1" || name != "Test Artist" || !ignoreSingles || ignoreCompilations || !monitored {
|
||||
t.Errorf("unexpected row values: id=%q name=%q ignoreSingles=%v ignoreCompilations=%v monitored=%v",
|
||||
id, name, ignoreSingles, ignoreCompilations, monitored)
|
||||
if id != "artist-1" || name != "Test Artist" || !ignoreSingles || ignoreCompilations || ignoreLive || ignoreRemix || !monitored {
|
||||
t.Errorf("unexpected row values: id=%q name=%q ignoreSingles=%v ignoreCompilations=%v ignoreLive=%v ignoreRemix=%v monitored=%v",
|
||||
id, name, ignoreSingles, ignoreCompilations, ignoreLive, ignoreRemix, monitored)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,11 +206,8 @@ func TestMigrationTracking(t *testing.T) {
|
||||
t.Fatalf("query migrations count: %v", err)
|
||||
}
|
||||
|
||||
// We have 9 recorded migrations: artist_settings, external_releases,
|
||||
// local_albums, notifications_sent, cached_at column, secondary_types
|
||||
// column, the external_releases.artist_id index, the artist_settings mbid
|
||||
// column, and the artist_settings last_synced column.
|
||||
if count != 9 {
|
||||
t.Errorf("expected 9 applied migrations, got %d", count)
|
||||
// We now have 10 recorded migrations.
|
||||
if count != 10 {
|
||||
t.Errorf("expected 10 applied migrations, got %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user