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

* test: unskip AbsolutePath and i18n path-separator tests on Windows (#5381)

Signed-off-by: junkerderprovinz <jdp@braethoria.com>

* test: unskip metadata folder-PID test on Windows via path.Dir (#5381)

Signed-off-by: junkerderprovinz <jdp@braethoria.com>

* test(storage): make relative-folder assertion cross-platform and unskip on Windows (#5381)

Signed-off-by: junkerderprovinz <jdp@braethoria.com>

* fix(persistence): normalize folder-update-info paths with forward slashes on Windows (#5381)

Signed-off-by: junkerderprovinz <jdp@braethoria.com>

* review: drop folder-PID change, trim storage_test comment (#5381)

Revert model/metadata/persistent_ids.go to master: switching the `folder`
PID attribute from filepath.Dir to path.Dir would change the persistent IDs
of existing Windows libraries and needs a migration path, so it is out of
scope for this PR. The matching test unskip is reverted with it, leaving
#TBD-path-sep-metadata open in #5381.

Trim the core/storage/storage_test.go comment to two lines.

Signed-off-by: junkerderprovinz <jdp@braethoria.com>

---------

Signed-off-by: junkerderprovinz <jdp@braethoria.com>
Co-authored-by: Deluan Quintão <deluan@navidrome.org>
This commit is contained in:
Junker der Provinz 2026-08-19 17:50:32 +02:00 committed by GitHub
parent bd6b7a6686
commit c362519f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 14 deletions

View File

@ -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() {

View File

@ -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")

View File

@ -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")

View File

@ -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