add migration, more tests

This commit is contained in:
Kendall Garner 2023-12-09 21:58:50 -08:00
commit 40d29f2cb1
No known key found for this signature in database
GPG key ID: 18D2767419676C87
8 changed files with 261 additions and 16 deletions

View file

@ -0,0 +1,37 @@
{
"status": "ok",
"version": "1.8.0",
"type": "navidrome",
"serverVersion": "v0.0.0",
"openSubsonic": true,
"lyricsList": {
"structuredLyrics": [
{
"lang": "eng",
"line": [
{
"start": 18800,
"value": "We're no strangers to love"
},
{
"start": 22801,
"value": "You know the rules and so do I"
}
],
"synced": true
},
{
"lang": "xxx",
"line": [
{
"value": "We're no strangers to love"
},
{
"value": "You know the rules and so do I"
}
],
"synced": false
}
]
}
}

View file

@ -0,0 +1,20 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<lyricsList>
<structuredLyrics lang="eng" synced="true">
<line start="18800">
<value>We&#39;re no strangers to love</value>
</line>
<line start="22801">
<value>You know the rules and so do I</value>
</line>
</structuredLyrics>
<structuredLyrics lang="xxx" synced="false">
<line>
<value>We&#39;re no strangers to love</value>
</line>
<line>
<value>You know the rules and so do I</value>
</line>
</structuredLyrics>
</lyricsList>
</subsonic-response>

View file

@ -0,0 +1,8 @@
{
"status": "ok",
"version": "1.8.0",
"type": "navidrome",
"serverVersion": "v0.0.0",
"openSubsonic": true,
"lyricsList": {}
}

View file

@ -0,0 +1,3 @@
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0" openSubsonic="true">
<lyricsList></lyricsList>
</subsonic-response>

View file

@ -11,6 +11,7 @@ import (
"time"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/model"
. "github.com/navidrome/navidrome/server/subsonic/responses"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@ -795,4 +796,62 @@ var _ = Describe("Responses", func() {
})
})
})
Describe("getLyricsBySongId", func() {
BeforeEach(func() {
response.LyricsList = &LyricsList{}
})
Describe("without data", func() {
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
Describe("with data", func() {
BeforeEach(func() {
times := []int64{int64(18800), int64(22801)}
response.LyricsList.StructuredLyrics = model.Lyrics{
{
Lang: "eng",
Synced: true,
Line: []model.Line{
{
Start: &times[0],
Value: "We're no strangers to love",
},
{
Start: &times[1],
Value: "You know the rules and so do I",
},
},
},
{
Lang: "xxx",
Synced: false,
Line: []model.Line{
{
Value: "We're no strangers to love",
},
{
Value: "You know the rules and so do I",
},
},
},
}
})
It("should match .XML", func() {
Expect(xml.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
It("should match .JSON", func() {
Expect(json.MarshalIndent(response, "", " ")).To(MatchSnapshot())
})
})
})
})