Skip to content

🎧 Your Personal Streaming Service

test: unskip path-separator tests on Windows (#5381) (#5916)

Junker der Provinzc362519f76d1
diff --git a/core/common_test.go b/core/common_test.go
index 0d6e3a299..f57ea8d38 100644
--- a/core/common_test.go
+++ b/core/common_test.go
@@ -2,6 +2,7 @@ package core
import (
"context"
+ "path/filepath"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@@ -41,10 +42,9 @@ var _ = Describe("common.go", func() {
})
It("returns the absolute path when library exists", func() {
- tests.SkipOnWindows("path separator bug (#TBD-path-sep-core)")
ctx := context.Background()
abs := AbsolutePath(ctx, ds, libId, path)
- Expect(abs).To(Equal("/library/root/music/file.mp3"))
+ Expect(abs).To(Equal(filepath.FromSlash("/library/root/music/file.mp3")))
})
It("returns the original path if library not found", func() {
diff --git a/core/storage/storage_test.go b/core/storage/storage_test.go
index 336b5a7a9..03904d086 100644
--- a/core/storage/storage_test.go
+++ b/core/storage/storage_test.go
@@ -7,7 +7,6 @@ import (
"runtime"
"testing"
- "github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@@ -56,13 +55,16 @@ var _ = Describe("Storage", func() {
Expect(s.(*fakeLocalStorage).u.Path).To(Equal("/tmp"))
})
It("should return a file implementation for a relative folder", func() {
- tests.SkipOnWindows("path separator bug (#TBD-path-sep-storage)")
s, err := For("tmp")
Expect(err).ToNot(HaveOccurred())
cwd, _ := os.Getwd()
Expect(s).To(BeAssignableToTypeOf(&fakeLocalStorage{}))
- Expect(s.(*fakeLocalStorage).u.Scheme).To(Equal("file"))
- Expect(s.(*fakeLocalStorage).u.Path).To(Equal(filepath.Join(cwd, "tmp")))
+ u := s.(*fakeLocalStorage).u
+ Expect(u.Scheme).To(Equal("file"))
+ // On Windows the drive letter lands in u.Host, so re-join it with
+ // u.Path (as newLocalStorage does) to keep the assertion OS-independent.
+ got := filepath.Join(u.Host, filepath.FromSlash(u.Path))
+ Expect(got).To(Equal(filepath.Join(cwd, "tmp")))
})
It("should return error if schema is unregistered", func() {
_, err := For("webdav:///tmp")
diff --git a/persistence/folder_repository_test.go b/persistence/folder_repository_test.go
index b429cecb9..545d8ad49 100644
--- a/persistence/folder_repository_test.go
+++ b/persistence/folder_repository_test.go
@@ -8,7 +8,6 @@ import (
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request"
- "github.com/navidrome/navidrome/tests"
"github.com/navidrome/navidrome/utils/slice"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@@ -137,7 +136,6 @@ var _ = Describe("FolderRepository", func() {
})
It("includes all child folders when querying parent", func() {
- tests.SkipOnWindows("path storage (#TBD-path-sep-persistence)")
// Create a parent folder with multiple children
parent := model.NewFolder(testLib, "TestParent/Music")
child1 := model.NewFolder(testLib, "TestParent/Music/Rock/Queen")
@@ -159,7 +157,6 @@ var _ = Describe("FolderRepository", func() {
})
It("excludes children from other libraries", func() {
- tests.SkipOnWindows("path storage (#TBD-path-sep-persistence)")
// Create parent in testLib
parent := model.NewFolder(testLib, "TestIsolation/Parent")
child := model.NewFolder(testLib, "TestIsolation/Parent/Child")
@@ -185,7 +182,6 @@ var _ = Describe("FolderRepository", func() {
})
It("excludes missing children when querying parent", func() {
- tests.SkipOnWindows("path storage (#TBD-path-sep-persistence)")
// Create parent and children, mark one as missing
parent := model.NewFolder(testLib, "TestMissingChild/Parent")
child1 := model.NewFolder(testLib, "TestMissingChild/Parent/Child1")
@@ -206,7 +202,6 @@ var _ = Describe("FolderRepository", func() {
})
It("handles mix of existing and non-existing target paths", func() {
- tests.SkipOnWindows("path storage (#TBD-path-sep-persistence)")
// Create folders for one path but not the other
existingParent := model.NewFolder(testLib, "TestMixed/Exists")
existingChild := model.NewFolder(testLib, "TestMixed/Exists/Child")
diff --git a/server/nativeapi/translations_test.go b/server/nativeapi/translations_test.go
index 77c088f6f..1c641da77 100644
--- a/server/nativeapi/translations_test.go
+++ b/server/nativeapi/translations_test.go
@@ -5,12 +5,12 @@ import (
"io"
"io/fs"
"os"
+ "path"
"path/filepath"
"testing/fstest"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/resources"
- "github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
@@ -18,13 +18,12 @@ import (
var _ = Describe("Translations", func() {
Describe("I18n files", func() {
It("contains only valid json language files", func() {
- tests.SkipOnWindows("path separator bug (#TBD-path-sep-nativeapi)")
fsys := resources.FS()
dir, _ := fsys.Open(consts.I18nFolder)
files, _ := dir.(fs.ReadDirFile).ReadDir(-1)
for _, f := range files {
name := filepath.Base(f.Name())
- filePath := filepath.Join(consts.I18nFolder, name)
+ filePath := path.Join(consts.I18nFolder, name)
file, _ := fsys.Open(filePath)
data, _ := io.ReadAll(file)
var out map[string]any