mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 21:57:06 +02:00
Implemented subsonic loves import
This commit is contained in:
parent
c4ae2eda48
commit
baed52dacc
5 changed files with 159 additions and 0 deletions
63
backends/subsonic/subsonic_test.go
Normal file
63
backends/subsonic/subsonic_test.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
package subsonic_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
go_subsonic "github.com/delucks/go-subsonic"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uploadedlobster.com/scotty/backends/subsonic"
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
||||
config := viper.New()
|
||||
config.Set("server-url", "https://subsonic.example.com")
|
||||
config.Set("token", "thetoken")
|
||||
backend := subsonic.SubsonicApiBackend{}.FromConfig(config)
|
||||
assert.IsType(t, subsonic.SubsonicApiBackend{}, backend)
|
||||
}
|
||||
|
||||
func TestSongToLove(t *testing.T) {
|
||||
user := "outsidecontext"
|
||||
song := go_subsonic.Child{
|
||||
Starred: time.Unix(1699574369, 0),
|
||||
Title: "Oweynagat",
|
||||
Album: "Here Now, There Then",
|
||||
Artist: "Dool",
|
||||
Duration: 414,
|
||||
Genre: "psychedelic rock",
|
||||
DiscNumber: 1,
|
||||
Track: 5,
|
||||
}
|
||||
love := subsonic.SongToLove(song, user)
|
||||
assert.Equal(t, time.Unix(1699574369, 0).Unix(), love.Created.Unix())
|
||||
assert.Equal(t, user, love.UserName)
|
||||
assert.Equal(t, time.Duration(414*time.Second), love.Duration)
|
||||
assert.Equal(t, song.Title, love.TrackName)
|
||||
assert.Equal(t, song.Album, love.ReleaseName)
|
||||
assert.Equal(t, []string{song.Artist}, love.ArtistNames)
|
||||
assert.Equal(t, song.Track, love.Track.TrackNumber)
|
||||
assert.Equal(t, []string{song.Genre}, love.Track.Tags)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue