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:
@@ -56,13 +56,7 @@ func TestAdminLibraryCoverage_MixedRowsReturnCorrectBuckets(t *testing.T) {
|
|||||||
admin := seedUser(t, pool, "covgauge2", "pw", true)
|
admin := seedUser(t, pool, "covgauge2", "pw", true)
|
||||||
|
|
||||||
// Seed an artist for FK satisfaction.
|
// Seed an artist for FK satisfaction.
|
||||||
var artistID string
|
artist := seedArtist(t, pool, "Coverage Test")
|
||||||
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Seed albums covering each bucket. Use distinct titles to avoid the
|
// Seed albums covering each bucket. Use distinct titles to avoid the
|
||||||
// unique (artist_id, title) constraint. Distinct mbids where set so
|
// unique (artist_id, title) constraint. Distinct mbids where set so
|
||||||
@@ -72,24 +66,24 @@ func TestAdminLibraryCoverage_MixedRowsReturnCorrectBuckets(t *testing.T) {
|
|||||||
source *string
|
source *string
|
||||||
mbid *string
|
mbid *string
|
||||||
}
|
}
|
||||||
none := "none"
|
sourceNone := "none"
|
||||||
sidecar := "sidecar"
|
sourceSidecar := "sidecar"
|
||||||
mbcaa := "mbcaa"
|
sourceMbcaa := "mbcaa"
|
||||||
mbid1 := "11111111-1111-1111-1111-111111111111"
|
mbid1 := "11111111-1111-1111-1111-111111111111"
|
||||||
mbid2 := "22222222-2222-2222-2222-222222222222"
|
mbid2 := "22222222-2222-2222-2222-222222222222"
|
||||||
mbid3 := "33333333-3333-3333-3333-333333333333"
|
mbid3 := "33333333-3333-3333-3333-333333333333"
|
||||||
rows := []seed{
|
rows := []seed{
|
||||||
{title: "WithArtSidecar", source: &sidecar, mbid: &mbid1}, // with_art
|
{title: "WithArtSidecar", source: &sourceSidecar, mbid: &mbid1}, // with_art
|
||||||
{title: "WithArtMbcaa", source: &mbcaa, mbid: &mbid2}, // with_art
|
{title: "WithArtMbcaa", source: &sourceMbcaa, mbid: &mbid2}, // with_art
|
||||||
{title: "PendingHasMbid", source: nil, mbid: &mbid3}, // pending (eligible)
|
{title: "PendingHasMbid", source: nil, mbid: &mbid3}, // pending (eligible)
|
||||||
{title: "PendingNoMbid", source: nil, mbid: nil}, // pending + pending_no_mbid
|
{title: "PendingNoMbid", source: nil, mbid: nil}, // pending + pending_no_mbid
|
||||||
{title: "Settled", source: &none, mbid: nil}, // settled (no mbid is fine here)
|
{title: "Settled", source: &sourceNone, mbid: nil}, // settled (no mbid is fine here)
|
||||||
}
|
}
|
||||||
for _, s := range rows {
|
for _, s := range rows {
|
||||||
if _, err := pool.Exec(context.Background(), `
|
if _, err := pool.Exec(context.Background(), `
|
||||||
INSERT INTO albums (artist_id, title, sort_title, cover_art_source, mbid)
|
INSERT INTO albums (artist_id, title, sort_title, cover_art_source, mbid)
|
||||||
VALUES ($1, $2, $3, $4, $5)
|
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)
|
t.Fatalf("seed album %q: %v", s.title, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user