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.
This commit is contained in:
@@ -180,14 +180,9 @@ var _ = Describe("CacheWarmer", func() {
|
|||||||
cw := NewCacheWarmer(aw, fc).(*cacheWarmer)
|
cw := NewCacheWarmer(aw, fc).(*cacheWarmer)
|
||||||
cw.PreCache(model.MustParseArtworkID("al-1"))
|
cw.PreCache(model.MustParseArtworkID("al-1"))
|
||||||
|
|
||||||
Eventually(func() int {
|
Eventually(func() []int {
|
||||||
cw.mutex.Lock()
|
return aw.getCachedSizes()
|
||||||
defer cw.mutex.Unlock()
|
}).Should(ContainElements(consts.UICoverArtSize, consts.UIThumbnailSize))
|
||||||
return len(cw.buffer)
|
|
||||||
}).Should(Equal(0))
|
|
||||||
|
|
||||||
sizes := aw.getCachedSizes()
|
|
||||||
Expect(sizes).To(ContainElements(consts.UICoverArtSize, consts.UIThumbnailSize))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user