diff --git a/internal/api/admin_coverage_test.go b/internal/api/admin_coverage_test.go index 45e2f482..dd4e3c07 100644 --- a/internal/api/admin_coverage_test.go +++ b/internal/api/admin_coverage_test.go @@ -56,13 +56,7 @@ func TestAdminLibraryCoverage_MixedRowsReturnCorrectBuckets(t *testing.T) { admin := seedUser(t, pool, "covgauge2", "pw", true) // Seed an artist for FK satisfaction. - var artistID string - if err := pool.QueryRow(context.Background(), ` - INSERT INTO artists (name, sort_name) VALUES ('Coverage Test', 'coverage test') - RETURNING id - `).Scan(&artistID); err != nil { - t.Fatalf("seed artist: %v", err) - } + artist := seedArtist(t, pool, "Coverage Test") // Seed albums covering each bucket. Use distinct titles to avoid the // unique (artist_id, title) constraint. Distinct mbids where set so @@ -72,24 +66,24 @@ func TestAdminLibraryCoverage_MixedRowsReturnCorrectBuckets(t *testing.T) { source *string mbid *string } - none := "none" - sidecar := "sidecar" - mbcaa := "mbcaa" + sourceNone := "none" + sourceSidecar := "sidecar" + sourceMbcaa := "mbcaa" mbid1 := "11111111-1111-1111-1111-111111111111" mbid2 := "22222222-2222-2222-2222-222222222222" mbid3 := "33333333-3333-3333-3333-333333333333" rows := []seed{ - {title: "WithArtSidecar", source: &sidecar, mbid: &mbid1}, // with_art - {title: "WithArtMbcaa", source: &mbcaa, mbid: &mbid2}, // with_art - {title: "PendingHasMbid", source: nil, mbid: &mbid3}, // pending (eligible) - {title: "PendingNoMbid", source: nil, mbid: nil}, // pending + pending_no_mbid - {title: "Settled", source: &none, mbid: nil}, // settled (no mbid is fine here) + {title: "WithArtSidecar", source: &sourceSidecar, mbid: &mbid1}, // with_art + {title: "WithArtMbcaa", source: &sourceMbcaa, mbid: &mbid2}, // with_art + {title: "PendingHasMbid", source: nil, mbid: &mbid3}, // pending (eligible) + {title: "PendingNoMbid", source: nil, mbid: nil}, // pending + pending_no_mbid + {title: "Settled", source: &sourceNone, mbid: nil}, // settled (no mbid is fine here) } for _, s := range rows { if _, err := pool.Exec(context.Background(), ` INSERT INTO albums (artist_id, title, sort_title, cover_art_source, mbid) VALUES ($1, $2, $3, $4, $5) - `, artistID, s.title, s.title, s.source, s.mbid); err != nil { + `, artist.ID, s.title, s.title, s.source, s.mbid); err != nil { t.Fatalf("seed album %q: %v", s.title, err) } }