chore(server/m7-coverage-gauge): align coverage test with peer style

Code-review polish on admin_coverage_test.go:
- Replace inline artist-seed SQL with the seedArtist helper used
  across the rest of the api test suite (admin_covers_test.go,
  likes_test.go, me_history_test.go, admin_quarantine_test.go).
- Rename the cover_art_source pointer locals from none/sidecar/mbcaa
  to sourceNone/sourceSidecar/sourceMbcaa so they don't read like
  zero-value identifiers.
This commit is contained in:
2026-05-06 10:06:38 -04:00
parent a1d295ebac
commit 97cca4411a
+10 -16
View File
@@ -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)
}
}