mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-16 10:09:28 +02:00
50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
/*
|
|
Copyright © 2023 Philipp Wolfer <phw@uploadedlobster.com>
|
|
|
|
Scotty is free software: you can redistribute it and/or modify it under the
|
|
terms of the GNU General Public License as published by the Free Software
|
|
Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
Scotty is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
Scotty. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package deezer_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/spf13/viper"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.uploadedlobster.com/scotty/backends/deezer"
|
|
)
|
|
|
|
func TestFromConfig(t *testing.T) {
|
|
config := viper.New()
|
|
config.Set("client-id", "someclientid")
|
|
config.Set("client-secret", "someclientsecret")
|
|
backend := (&deezer.DeezerApiBackend{}).FromConfig(config)
|
|
assert.IsType(t, &deezer.DeezerApiBackend{}, backend)
|
|
}
|
|
|
|
func TestLovedTrackAsLove(t *testing.T) {
|
|
data, err := os.ReadFile("testdata/track.json")
|
|
require.NoError(t, err)
|
|
track := deezer.LovedTrack{}
|
|
err = json.Unmarshal(data, &track)
|
|
require.NoError(t, err)
|
|
love := track.AsLove()
|
|
assert.Equal(t, time.Unix(1700743848, 0), love.Created)
|
|
assert.Equal(t, time.Duration(255*time.Second), love.Duration)
|
|
assert.Equal(t, "Never Take Me Alive", love.TrackName)
|
|
assert.Equal(t, "Outland", love.ReleaseName)
|
|
assert.Equal(t, "Spear Of Destiny", love.ArtistName())
|
|
}
|