Remove temp folders after tests

This commit is contained in:
Deluan 2021-10-28 10:40:31 -04:00
parent fa3471f527
commit 66a9cbb7d9
6 changed files with 30 additions and 15 deletions

View file

@ -88,19 +88,25 @@ var _ = Describe("AlbumRepository", func() {
})
Describe("getCoverFromPath", func() {
testFolder, _ := os.MkdirTemp("", "album_persistence_tests")
if err := os.MkdirAll(testFolder, 0777); err != nil {
panic(err)
}
if _, err := os.Create(filepath.Join(testFolder, "Cover.jpeg")); err != nil {
panic(err)
}
if _, err := os.Create(filepath.Join(testFolder, "FRONT.PNG")); err != nil {
panic(err)
}
var testFolder, testPath, embeddedPath string
BeforeEach(func() {
testFolder, _ = os.MkdirTemp("", "album_persistence_tests")
if err := os.MkdirAll(testFolder, 0777); err != nil {
panic(err)
}
if _, err := os.Create(filepath.Join(testFolder, "Cover.jpeg")); err != nil {
panic(err)
}
if _, err := os.Create(filepath.Join(testFolder, "FRONT.PNG")); err != nil {
panic(err)
}
testPath = filepath.Join(testFolder, "somefile.test")
embeddedPath = filepath.Join(testFolder, "somefile.mp3")
})
AfterEach(func() {
_ = os.RemoveAll(testFolder)
})
testPath := filepath.Join(testFolder, "somefile.test")
embeddedPath := filepath.Join(testFolder, "somefile.mp3")
It("returns audio file for embedded cover", func() {
conf.Server.CoverArtPriority = "embedded, cover.*, front.*"
Expect(getCoverFromPath(testPath, embeddedPath)).To(Equal(""))