Refactor FileCache, allow disabling Trasncoding cache

This commit is contained in:
Deluan
2020-07-24 12:42:11 -04:00
parent b795ad55a3
commit 433e31acc8
5 changed files with 191 additions and 92 deletions
+14 -4
View File
@@ -18,20 +18,30 @@ var _ = Describe("File Caches", func() {
os.RemoveAll(conf.Server.DataFolder)
})
Describe("newFileCache", func() {
Describe("NewFileCache", func() {
It("creates the cache folder", func() {
Expect(newFileCache("test", "1k", "test", 10)).ToNot(BeNil())
Expect(NewFileCache("test", "1k", "test", 10, nil)).ToNot(BeNil())
_, err := os.Stat(filepath.Join(conf.Server.DataFolder, "test"))
Expect(os.IsNotExist(err)).To(BeFalse())
})
It("creates the cache folder with invalid size", func() {
Expect(newFileCache("test", "abc", "test", 10)).ToNot(BeNil())
fc, err := NewFileCache("test", "abc", "test", 10, nil)
Expect(err).To(BeNil())
Expect(fc.cache).ToNot(BeNil())
Expect(fc.disabled).To(BeFalse())
})
It("returns empty if cache size is '0'", func() {
Expect(newFileCache("test", "0", "test", 10)).To(BeNil())
fc, err := NewFileCache("test", "0", "test", 10, nil)
Expect(err).To(BeNil())
Expect(fc.cache).To(BeNil())
Expect(fc.disabled).To(BeTrue())
})
})
Describe("FileCache", func() {
})
})