fix(server): memory leak in cache warmer (#4095)

* Prevent cache warmer memory leak when cache disabled

* refactor(tests): replace disabledCache with mockFileCache in CacheWarmer tests

Signed-off-by: Deluan <deluan@navidrome.org>

* test(cache): enhance CacheWarmer tests for initialization, buffer management, and error handling

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan Quintão
2025-05-21 21:48:49 -04:00
committed by GitHub
parent dd1d3907b4
commit 6731787053
4 changed files with 253 additions and 0 deletions
+7
View File
@@ -50,6 +50,13 @@ var _ = Describe("File Caches", func() {
Expect(fc.cache).To(BeNil())
Expect(fc.disabled).To(BeTrue())
})
It("reports when cache is disabled", func() {
fc := callNewFileCache("test", "0", "test", 0, nil)
Expect(fc.Disabled(context.Background())).To(BeTrue())
fc = callNewFileCache("test", "1KB", "test", 0, nil)
Expect(fc.Disabled(context.Background())).To(BeFalse())
})
})
Describe("FileCache", func() {