mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 13:07:36 +03:00
Small readability improvement in MergeFS tests
This commit is contained in:
parent
2b33ef72e3
commit
fd61b29a84
2 changed files with 10 additions and 10 deletions
|
@ -101,6 +101,6 @@ func (d *mergedDir) ReadDir(count int) ([]fs.DirEntry, error) {
|
||||||
|
|
||||||
func (d *mergedDir) Close() error { return nil }
|
func (d *mergedDir) Close() error { return nil }
|
||||||
func (d *mergedDir) Stat() (fs.FileInfo, error) { return d.info, nil }
|
func (d *mergedDir) Stat() (fs.FileInfo, error) { return d.info, nil }
|
||||||
func (d *mergedDir) Read([]byte) (n int, err error) {
|
func (d *mergedDir) Read([]byte) (int, error) {
|
||||||
return 0, &fs.PathError{Op: "read", Path: d.name, Err: errors.New("is a directory")}
|
return 0, &fs.PathError{Op: "read", Path: d.name, Err: errors.New("is a directory")}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,13 @@ import (
|
||||||
|
|
||||||
var _ = Describe("MergeFS", func() {
|
var _ = Describe("MergeFS", func() {
|
||||||
var baseName, overlayName string
|
var baseName, overlayName string
|
||||||
var baseDir, overlayDir, mergedDir fs.FS
|
var mergedDir fs.FS
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
baseName, _ = os.MkdirTemp("", "merge_fs_base_test")
|
baseName, _ = os.MkdirTemp("", "merge_fs_base_test")
|
||||||
overlayName, _ = os.MkdirTemp("", "merge_fs_overlay_test")
|
overlayName, _ = os.MkdirTemp("", "merge_fs_overlay_test")
|
||||||
baseDir = os.DirFS(baseName)
|
baseDir := os.DirFS(baseName)
|
||||||
overlayDir = os.DirFS(overlayName)
|
overlayDir := os.DirFS(overlayName)
|
||||||
mergedDir = utils.MergeFS{Base: baseDir, Overlay: overlayDir}
|
mergedDir = utils.MergeFS{Base: baseDir, Overlay: overlayDir}
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
@ -79,21 +79,21 @@ var _ = Describe("MergeFS", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("allows to seek to the beginning of the directory", func() {
|
It("allows to seek to the beginning of the directory", func() {
|
||||||
_f(baseName, "1111")
|
_f(baseName, "1111.txt")
|
||||||
_f(baseName, "2222")
|
_f(baseName, "2222.txt")
|
||||||
_f(baseName, "3333")
|
_f(baseName, "3333.txt")
|
||||||
|
|
||||||
dir, err := mergedDir.Open(".")
|
dir, err := mergedDir.Open(".")
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
|
||||||
list, _ := dir.(fs.ReadDirFile).ReadDir(2)
|
list, _ := dir.(fs.ReadDirFile).ReadDir(2)
|
||||||
Expect(list).To(HaveLen(2))
|
Expect(list).To(HaveLen(2))
|
||||||
Expect(list[0].Name()).To(Equal("1111"))
|
Expect(list[0].Name()).To(Equal("1111.txt"))
|
||||||
Expect(list[1].Name()).To(Equal("2222"))
|
Expect(list[1].Name()).To(Equal("2222.txt"))
|
||||||
|
|
||||||
list, _ = dir.(fs.ReadDirFile).ReadDir(2)
|
list, _ = dir.(fs.ReadDirFile).ReadDir(2)
|
||||||
Expect(list).To(HaveLen(1))
|
Expect(list).To(HaveLen(1))
|
||||||
Expect(list[0].Name()).To(Equal("3333"))
|
Expect(list[0].Name()).To(Equal("3333.txt"))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue