mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-21 09:29:46 +01:00
Rebasing onto master's Podcasting-branch-unrelated changes surfaced several integration gaps the merge conflicts didn't catch: - conf.Server.DataFolder is now a Dir type, not a string; podcasts.go and its tests needed .String()/conf.NewDir() at each call site. - subsonic.New() gained the podcasts.Podcasts parameter; several e2e/unit test call sites elsewhere in the tree were still passing the old arg count. - The uniform-canonical-ids migration (dated after our podcast migrations, so it runs against a schema that already has the podcast tables) didn't know about the new podcast_* id columns, leaving them unrewritten while everything else (including podcast_episode.stream_id's matching media_file.id) got canonicalized. - opensubsonic_test.go's expected extension count was miscounted during conflict resolution (9 Podcasting 2.0 extensions, not 7). - .gitignore's unanchored `podcasts/` entry from an earlier commit accidentally matched core/podcasts/ (source) in addition to the downloaded-episode directory; anchored both to their actual paths.
121 lines
5.9 KiB
Go
121 lines
5.9 KiB
Go
package subsonic_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
|
|
sonicsvc "github.com/navidrome/navidrome/core/sonic"
|
|
"github.com/navidrome/navidrome/server/subsonic"
|
|
"github.com/navidrome/navidrome/server/subsonic/responses"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
type mockSonicPluginLoader struct {
|
|
names []string
|
|
}
|
|
|
|
func (m *mockSonicPluginLoader) PluginNames(capability string) []string {
|
|
if capability == "SonicSimilarity" {
|
|
return m.names
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *mockSonicPluginLoader) LoadSonicSimilarity(_ string) (sonicsvc.Provider, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
var _ = Describe("GetOpenSubsonicExtensions", func() {
|
|
var (
|
|
router *subsonic.Router
|
|
w *httptest.ResponseRecorder
|
|
r *http.Request
|
|
)
|
|
|
|
JustBeforeEach(func() {
|
|
w = httptest.NewRecorder()
|
|
r = httptest.NewRequest("GET", "/getOpenSubsonicExtensions?f=json", nil)
|
|
})
|
|
|
|
Context("without sonic similarity plugin", func() {
|
|
BeforeEach(func() {
|
|
router = subsonic.New(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
|
})
|
|
|
|
It("should return the base 17 OpenSubsonicExtensions without sonicSimilarity", func() {
|
|
router.ServeHTTP(w, r)
|
|
|
|
// Make sure the endpoint is public, by not passing any authentication
|
|
Expect(w.Code).To(Equal(http.StatusOK))
|
|
Expect(w.Header().Get("Content-Type")).To(Equal("application/json"))
|
|
|
|
var response responses.JsonWrapper
|
|
err := json.Unmarshal(w.Body.Bytes(), &response)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(*response.Subsonic.OpenSubsonicExtensions).To(SatisfyAll(
|
|
HaveLen(17),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "transcodeOffset", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "formPost", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "songLyrics", Versions: []int32{1, 2}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "indexBasedQueue", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "transcoding", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "playbackReport", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "topSongsByArtistId", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "getPodcastEpisode", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastChapters", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastTranscripts", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastSeason", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPerson", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastFunding", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastMedium", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPodroll", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastLiveItem", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPodping", Versions: []int32{1}}),
|
|
))
|
|
Expect(*response.Subsonic.OpenSubsonicExtensions).NotTo(
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "sonicSimilarity", Versions: []int32{1}}),
|
|
)
|
|
})
|
|
})
|
|
|
|
Context("with sonic similarity plugin", func() {
|
|
BeforeEach(func() {
|
|
sonicService := sonicsvc.New(nil, &mockSonicPluginLoader{names: []string{"test-plugin"}}, nil)
|
|
router = subsonic.New(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, sonicService)
|
|
})
|
|
|
|
It("should return 18 extensions including all podcast 2.0 and sonicSimilarity", func() {
|
|
router.ServeHTTP(w, r)
|
|
|
|
Expect(w.Code).To(Equal(http.StatusOK))
|
|
Expect(w.Header().Get("Content-Type")).To(Equal("application/json"))
|
|
|
|
var response responses.JsonWrapper
|
|
err := json.Unmarshal(w.Body.Bytes(), &response)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(*response.Subsonic.OpenSubsonicExtensions).To(SatisfyAll(
|
|
HaveLen(18),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "transcodeOffset", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "formPost", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "songLyrics", Versions: []int32{1, 2}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "indexBasedQueue", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "transcoding", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "playbackReport", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "topSongsByArtistId", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "getPodcastEpisode", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastChapters", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastTranscripts", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastSeason", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPerson", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastFunding", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastMedium", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPodroll", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastLiveItem", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "podcastPodping", Versions: []int32{1}}),
|
|
ContainElement(responses.OpenSubsonicExtension{Name: "sonicSimilarity", Versions: []int32{1}}),
|
|
))
|
|
})
|
|
})
|
|
})
|