test(coverart): DrainsNullSourceOnly — stamp id2 'none' at current version

The test marked id2 'none' via SetAlbumCover, which (covers.sql:42)
does NOT set cover_art_sources_version. ListAlbumsMissingCover treats
'none' AND version != current as eligible, so id2 (version 0, current
1) was wrongly drained → processed=2. The comment's intent ("'none'
with current version → not drained") requires SetAlbumCoverWithVersion
(albums.sql) stamped with the live GetCurrentSourcesVersion — the same
value EnrichBatch compares against. Test-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-17 22:22:44 -04:00
parent 5e91efe695
commit a86b7a5e07
+17 -8
View File
@@ -262,18 +262,27 @@ func TestEnrichBatch_DrainsNullSourceOnly(t *testing.T) {
}
id2, _ := seedAlbumWithTrack(t, pool, "Drain2", "B", "")
// Pre-mark id2 as 'none' with current version — should NOT be drained by EnrichBatch
// (ListAlbumsMissingCover only returns stale-version 'none').
src := "none"
if err := dbq.New(pool).SetAlbumCover(context.Background(), dbq.SetAlbumCoverParams{
ID: id2, Column2: "", CoverArtSource: &src,
}); err != nil {
t.Fatal(err)
}
resetRegistryForTests() // deterministic empty registry
t.Cleanup(resetRegistryForTests)
e := newTestEnricher(t, pool)
// Pre-mark id2 as 'none' AT the current sources version so
// ListAlbumsMissingCover excludes it (it only returns NULL or
// stale-version 'none'). SetAlbumCover does NOT stamp the version;
// SetAlbumCoverWithVersion does — use the live current version, the
// same value EnrichBatch compares against.
curVer, err := dbq.New(pool).GetCurrentSourcesVersion(context.Background())
if err != nil {
t.Fatalf("current version: %v", err)
}
src := "none"
if err := dbq.New(pool).SetAlbumCoverWithVersion(context.Background(), dbq.SetAlbumCoverWithVersionParams{
ID: id2, CoverArtPath: nil, CoverArtSource: &src, CoverArtSourcesVersion: curVer,
}); err != nil {
t.Fatal(err)
}
processed, _, _, err := e.EnrichBatch(context.Background(), 100, nil)
if err != nil {
t.Fatalf("batch: %v", err)