Files
navidrome/plugins/manager_plugin_test.go
Jorge Pardo Pardo 85e9982b43 feat(plugins): add path to Scrobbler and Lyrics plugin TrackInfo (#5339)
* feat: add Path to TrackInfo struct

* refactor: improve naming to follow the rest of the code

* test: add tests

* fix: actually check for filesystem permission

* refactor: remove library logic from specific plugins

* refactor: move hasFilesystemPermission to a Manifest method

* test(plugins): add unit tests for hasLibraryFilesystemAccess method

Signed-off-by: Deluan <deluan@navidrome.org>

* refactor(plugins): remove hasFilesystemPerm field and use manifest for filesystem permission checks

Signed-off-by: Deluan <deluan@navidrome.org>

* refactor(plugins): streamline library filesystem access checks in lyrics and scrobbler adapters

Signed-off-by: Deluan <deluan@navidrome.org>

---------

Signed-off-by: Deluan <deluan@navidrome.org>
Co-authored-by: Deluan <deluan@navidrome.org>
2026-04-12 10:27:58 -04:00

35 lines
1.1 KiB
Go

package plugins
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("plugin", func() {
Describe("hasLibraryFilesystemAccess", func() {
fsManifest := &Manifest{
Permissions: &Permissions{
Library: &LibraryPermission{Filesystem: true},
},
}
It("returns false when the manifest does not grant filesystem permission", func() {
p := &plugin{manifest: &Manifest{}, libraries: newLibraryAccess(nil, true)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeFalse())
})
It("returns true for any library when allLibraries is set", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess(nil, true)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(42)).To(BeTrue())
})
It("returns true only for libraries in the allowed list", func() {
p := &plugin{manifest: fsManifest, libraries: newLibraryAccess([]int{1, 3}, false)}
Expect(p.hasLibraryFilesystemAccess(1)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(3)).To(BeTrue())
Expect(p.hasLibraryFilesystemAccess(2)).To(BeFalse())
})
})
})