mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
use go:embed to simplify testdata loading
This commit is contained in:
parent
c4193f42a1
commit
dd501df5c5
4 changed files with 35 additions and 25 deletions
|
@ -23,8 +23,8 @@ THE SOFTWARE.
|
|||
package spotify_test
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -32,11 +32,12 @@ import (
|
|||
"go.uploadedlobster.com/scotty/internal/backends/spotify"
|
||||
)
|
||||
|
||||
//go:embed testdata/recently-played.json
|
||||
var testRecentlyPlayed []byte
|
||||
|
||||
func TestRecentlyPlayedResult(t *testing.T) {
|
||||
data, err := os.ReadFile("testdata/recently-played.json")
|
||||
require.NoError(t, err)
|
||||
result := spotify.RecentlyPlayedResult{}
|
||||
err = json.Unmarshal(data, &result)
|
||||
err := json.Unmarshal(testRecentlyPlayed, &result)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert := assert.New(t)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue