navidrome/engine/file_caches_test.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
869 B
Go
Raw Normal View History

2020-04-09 19:15:01 +02:00
package engine
import (
"io/ioutil"
"os"
"path/filepath"
"github.com/deluan/navidrome/conf"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("File Caches", func() {
BeforeEach(func() {
conf.Server.DataFolder, _ = ioutil.TempDir("", "file_caches")
})
AfterEach(func() {
os.RemoveAll(conf.Server.DataFolder)
})
Describe("newFileCache", func() {
It("creates the cache folder", func() {
2020-04-09 19:36:05 +02:00
Expect(newFileCache("test", "1k", "test", 10)).ToNot(BeNil())
2020-04-09 19:15:01 +02:00
2020-04-09 19:36:05 +02:00
_, err := os.Stat(filepath.Join(conf.Server.DataFolder, "test"))
2020-04-09 19:15:01 +02:00
Expect(os.IsNotExist(err)).To(BeFalse())
})
2020-04-09 19:36:05 +02:00
It("creates the cache folder with invalid size", func() {
Expect(newFileCache("test", "abc", "test", 10)).ToNot(BeNil())
})
It("returns empty if cache size is '0'", func() {
Expect(newFileCache("test", "0", "test", 10)).To(BeNil())
})
2020-04-09 19:15:01 +02:00
})
})