diff --git a/internal/coverart/enricher_test.go b/internal/coverart/enricher_test.go index acb93d6e..27032762 100644 --- a/internal/coverart/enricher_test.go +++ b/internal/coverart/enricher_test.go @@ -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)