mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Restructured code, moved all modules into internal
For now all modules are considered internal. This might change later
This commit is contained in:
parent
f94e0f1e85
commit
857661ebf9
76 changed files with 121 additions and 68 deletions
65
internal/backends/deezer/models_test.go
Normal file
65
internal/backends/deezer/models_test.go
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
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"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uploadedlobster.com/scotty/internal/backends/deezer"
|
||||
)
|
||||
|
||||
func TestUserTracksResult(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/user-tracks.json")
|
||||
require.NoError(t, err)
|
||||
result := deezer.TracksResult{}
|
||||
err = json.Unmarshal(data, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert := assert.New(t)
|
||||
assert.Equal(4, result.Total)
|
||||
assert.Equal("https://api.deezer.com/user/me/tracks?limit=2&index=2",
|
||||
result.Next)
|
||||
require.Len(t, result.Tracks, 2)
|
||||
track1 := result.Tracks[0]
|
||||
assert.Equal(int64(1700743848), track1.AddedAt)
|
||||
assert.Equal("Never Take Me Alive", track1.Title)
|
||||
assert.Equal("Outland", track1.Album.Title)
|
||||
assert.Equal("Spear Of Destiny", track1.Artist.Name)
|
||||
}
|
||||
|
||||
func TestUserHistoryResult(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/user-history.json")
|
||||
require.NoError(t, err)
|
||||
result := deezer.HistoryResult{}
|
||||
err = json.Unmarshal(data, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert := assert.New(t)
|
||||
assert.Equal(12, result.Total)
|
||||
assert.Equal("https://api.deezer.com/user/me/history?limit=2&index=2",
|
||||
result.Next)
|
||||
require.Len(t, result.Tracks, 2)
|
||||
track1 := result.Tracks[0]
|
||||
assert.Equal(int64(1700753817), track1.Timestamp)
|
||||
assert.Equal("New Divide", track1.Title)
|
||||
assert.Equal("https://www.deezer.com/album/1346960", track1.Album.Link)
|
||||
assert.Equal("Linkin Park", track1.Artist.Name)
|
||||
assert.Equal("https://www.deezer.com/artist/92", track1.Artist.Link)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue