From f7b60c79527f4ddc10c960acb64d0975cb9ffdb8 Mon Sep 17 00:00:00 2001 From: Deluan Date: Thu, 19 Mar 2026 13:14:24 -0400 Subject: [PATCH] fix(tests): fix race condition in CacheWarmer pre-cache size test The test was checking that the buffer was drained before asserting on cached sizes, but the buffer is cleared before processBatch completes. Use Eventually on getCachedSizes() directly to properly wait for the artwork caching to finish. --- core/artwork/cache_warmer_test.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/core/artwork/cache_warmer_test.go b/core/artwork/cache_warmer_test.go index 47e187f4..6ddda00d 100644 --- a/core/artwork/cache_warmer_test.go +++ b/core/artwork/cache_warmer_test.go @@ -180,14 +180,9 @@ var _ = Describe("CacheWarmer", func() { cw := NewCacheWarmer(aw, fc).(*cacheWarmer) cw.PreCache(model.MustParseArtworkID("al-1")) - Eventually(func() int { - cw.mutex.Lock() - defer cw.mutex.Unlock() - return len(cw.buffer) - }).Should(Equal(0)) - - sizes := aw.getCachedSizes() - Expect(sizes).To(ContainElements(consts.UICoverArtSize, consts.UIThumbnailSize)) + Eventually(func() []int { + return aw.getCachedSizes() + }).Should(ContainElements(consts.UICoverArtSize, consts.UIThumbnailSize)) }) }) })