gomusic/auth_test.go
2025-02-12 14:31:19 +10:00

19 lines
604 B
Go

package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestgetSpotifyAuthURL(t *testing.T) {
// The result of this call is a serialized SpotifyToken struct
// The data is dynamic so we can't easily check it but we validate types/fields
res, err := getSpotifyToken(spotifyClientID, spotifyClientSecret)
if err != nil {
assert.Fail(t, err.Error())
}
testRes := &SpotifyToken{AccessToken: "example", TokenType: "Bearer", ExpiresIn: 100}
assert.IsType(t, testRes, res)
// This should always be "Bearer" according to spotify docs
assert.Equal(t, "Bearer", res.TokenType)
}