update
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled
This commit is contained in:
88
server/subsonic/playlists_test.go
Normal file
88
server/subsonic/playlists_test.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package subsonic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/navidrome/navidrome/core"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/tests"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ core.Playlists = (*fakePlaylists)(nil)
|
||||
|
||||
var _ = Describe("UpdatePlaylist", func() {
|
||||
var router *Router
|
||||
var ds model.DataStore
|
||||
var playlists *fakePlaylists
|
||||
|
||||
BeforeEach(func() {
|
||||
ds = &tests.MockDataStore{}
|
||||
playlists = &fakePlaylists{}
|
||||
router = New(ds, nil, nil, nil, nil, nil, nil, nil, playlists, nil, nil, nil, nil)
|
||||
})
|
||||
|
||||
It("clears the comment when parameter is empty", func() {
|
||||
r := newGetRequest("playlistId=123", "comment=")
|
||||
_, err := router.UpdatePlaylist(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(playlists.lastPlaylistID).To(Equal("123"))
|
||||
Expect(playlists.lastComment).ToNot(BeNil())
|
||||
Expect(*playlists.lastComment).To(Equal(""))
|
||||
})
|
||||
|
||||
It("leaves comment unchanged when parameter is missing", func() {
|
||||
r := newGetRequest("playlistId=123")
|
||||
_, err := router.UpdatePlaylist(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(playlists.lastPlaylistID).To(Equal("123"))
|
||||
Expect(playlists.lastComment).To(BeNil())
|
||||
})
|
||||
|
||||
It("sets public to true when parameter is 'true'", func() {
|
||||
r := newGetRequest("playlistId=123", "public=true")
|
||||
_, err := router.UpdatePlaylist(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(playlists.lastPlaylistID).To(Equal("123"))
|
||||
Expect(playlists.lastPublic).ToNot(BeNil())
|
||||
Expect(*playlists.lastPublic).To(BeTrue())
|
||||
})
|
||||
|
||||
It("sets public to false when parameter is 'false'", func() {
|
||||
r := newGetRequest("playlistId=123", "public=false")
|
||||
_, err := router.UpdatePlaylist(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(playlists.lastPlaylistID).To(Equal("123"))
|
||||
Expect(playlists.lastPublic).ToNot(BeNil())
|
||||
Expect(*playlists.lastPublic).To(BeFalse())
|
||||
})
|
||||
|
||||
It("leaves public unchanged when parameter is missing", func() {
|
||||
r := newGetRequest("playlistId=123")
|
||||
_, err := router.UpdatePlaylist(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(playlists.lastPlaylistID).To(Equal("123"))
|
||||
Expect(playlists.lastPublic).To(BeNil())
|
||||
})
|
||||
})
|
||||
|
||||
type fakePlaylists struct {
|
||||
core.Playlists
|
||||
lastPlaylistID string
|
||||
lastName *string
|
||||
lastComment *string
|
||||
lastPublic *bool
|
||||
lastAdd []string
|
||||
lastRemove []int
|
||||
}
|
||||
|
||||
func (f *fakePlaylists) Update(ctx context.Context, playlistID string, name *string, comment *string, public *bool, idsToAdd []string, idxToRemove []int) error {
|
||||
f.lastPlaylistID = playlistID
|
||||
f.lastName = name
|
||||
f.lastComment = comment
|
||||
f.lastPublic = public
|
||||
f.lastAdd = idsToAdd
|
||||
f.lastRemove = idxToRemove
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user