test: correct the A regression + finish B residual (coverart boot, stale system_test)

A redo: the prior commit truncated cover_art_sources_meta, but
SettingsService.reconcile() only READS that singleton (seeded once by
migration 0018) and never recreates it → ~45 coverart/api tests hard-
failed "get current sources version: no rows". Correct reset: keep
cover_art_provider_settings in the truncate set (boot idempotently
re-UpsertProviderSettings), drop cover_art_sources_meta from it, and
instead `UPDATE cover_art_sources_meta SET current_version = 1` so the
row survives while cross-test version accumulation is cleared.

B residual (exposed once the play_events FK fix let these run):
- seedQuarantine used reason 'test-hide', invalid for the
  lidarr_quarantine_reason enum (bad_rip/wrong_file/wrong_tags/
  duplicate/other) → use 'other'.
- TestBuildSystemPlaylists_SufficientActivity predated #411/#352: the
  variant switch errored on the 5 new seedless mixes and capped
  track_count at 25. Accept deep_cuts/rediscover/new_for_you/
  on_this_day/first_listens as seedless; raise the cap to 100.

Test/test-harness only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 15:05:18 -04:00
parent d212621eaa
commit 75163ea483
2 changed files with 24 additions and 12 deletions
+16 -7
View File
@@ -55,14 +55,13 @@ var dataTables = []string{
"playlist_tracks", "playlist_tracks",
"playlists", "playlists",
"library_changes", // M7 #357 — must reset to keep cursor isolated per test "library_changes", // M7 #357 — must reset to keep cursor isolated per test
// Cover-art provider settings + the monotonic source-version // SettingsService.reconcile() idempotently re-UpsertProviderSettings
// counter (cover_art_sources_meta, seeded at 1 by migration 0018). // for every registered provider at boot, so truncating this is the
// Not resetting these let the version accumulate across tests in // correct per-test reset (clears test-modified enabled/api_key rows).
// internal/coverart (CurrentVersion=4 want 1, key-only-bump // cover_art_sources_meta is NOT truncated — boot only READS it
// assertions, enricher source skips). SettingsService re-seeds both // (never recreates the singleton, seeded once by 0018); ResetDB
// at boot, so a truncated start is the correct fresh state. // resets its counter via UPDATE below instead.
"cover_art_provider_settings", "cover_art_provider_settings",
"cover_art_sources_meta",
"tracks", "tracks",
"albums", "albums",
"artists", "artists",
@@ -84,4 +83,14 @@ func ResetDB(t *testing.T, pool *pgxpool.Pool) {
); err != nil { ); err != nil {
t.Fatalf("dbtest.ResetDB delete test users: %v", err) t.Fatalf("dbtest.ResetDB delete test users: %v", err)
} }
// Reset the monotonic cover-art source-version counter to its
// post-migration seeded value. Truncating the row would break
// SettingsService boot, which reads (never recreates) this
// singleton; an UPDATE keeps the row while clearing cross-test
// version accumulation (CurrentVersion=4 want 1, key-only-bump).
if _, err := pool.Exec(ctx,
"UPDATE cover_art_sources_meta SET current_version = 1",
); err != nil {
t.Fatalf("dbtest.ResetDB reset cover-art version: %v", err)
}
} }
+8 -5
View File
@@ -45,7 +45,7 @@ func seedQuarantine(t *testing.T, pool *pgxpool.Pool, userID, trackID pgtype.UUI
t.Helper() t.Helper()
_, err := pool.Exec(context.Background(), ` _, err := pool.Exec(context.Background(), `
INSERT INTO lidarr_quarantine (user_id, track_id, reason) INSERT INTO lidarr_quarantine (user_id, track_id, reason)
VALUES ($1, $2, 'test-hide') VALUES ($1, $2, 'other')
`, userID, trackID) `, userID, trackID)
if err != nil { if err != nil {
t.Fatalf("seed quarantine: %v", err) t.Fatalf("seed quarantine: %v", err)
@@ -112,16 +112,19 @@ func TestBuildSystemPlaylists_SufficientActivity(t *testing.T) {
if !r.SeedArtistID.Valid { if !r.SeedArtistID.Valid {
t.Errorf("songs_like_artist row should have non-NULL seed_artist_id") t.Errorf("songs_like_artist row should have non-NULL seed_artist_id")
} }
case "discover": case "discover", "deep_cuts", "rediscover", "new_for_you", "on_this_day", "first_listens":
// Discover playlist is valid — no seed_artist_id required. // Discover + the #411 discovery mixes are all seedless —
// no seed_artist_id required.
default: default:
t.Errorf("unknown system_variant=%q", *r.SystemVariant) t.Errorf("unknown system_variant=%q", *r.SystemVariant)
} }
if r.TrackCount == 0 { if r.TrackCount == 0 {
t.Errorf("row %s: empty track_count", uuidString(r.ID)) t.Errorf("row %s: empty track_count", uuidString(r.ID))
} }
if r.TrackCount > 25 { // For-You / Discover / the discovery mixes are sized to ~100
t.Errorf("row %s: track_count=%d exceeds 25", uuidString(r.ID), r.TrackCount) // (#352/#411); songs_like_artist stays at systemMixLength (25).
if r.TrackCount > 100 {
t.Errorf("row %s: track_count=%d exceeds 100", uuidString(r.ID), r.TrackCount)
} }
} }
if !hasForYou { if !hasForYou {