mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-30 05:37:05 +02:00
Renamed Backend.FromConfig to Backend.InitConfig and added error handling
This commit is contained in:
parent
aad542850a
commit
0f4b04c641
21 changed files with 60 additions and 48 deletions
|
@ -52,10 +52,10 @@ func (b *SpotifyApiBackend) Options() []models.BackendOption {
|
|||
}}
|
||||
}
|
||||
|
||||
func (b *SpotifyApiBackend) FromConfig(config *config.ServiceConfig) models.Backend {
|
||||
func (b *SpotifyApiBackend) InitConfig(config *config.ServiceConfig) error {
|
||||
b.clientId = config.GetString("client-id")
|
||||
b.clientSecret = config.GetString("client-secret")
|
||||
return b
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *SpotifyApiBackend) OAuth2Strategy(redirectUrl *url.URL) auth.OAuth2Strategy {
|
||||
|
|
|
@ -38,13 +38,14 @@ var (
|
|||
testTrack []byte
|
||||
)
|
||||
|
||||
func TestFromConfig(t *testing.T) {
|
||||
func TestInitConfig(t *testing.T) {
|
||||
c := viper.New()
|
||||
c.Set("client-id", "someclientid")
|
||||
c.Set("client-secret", "someclientsecret")
|
||||
service := config.NewServiceConfig("test", c)
|
||||
backend := (&spotify.SpotifyApiBackend{}).FromConfig(&service)
|
||||
assert.IsType(t, &spotify.SpotifyApiBackend{}, backend)
|
||||
backend := spotify.SpotifyApiBackend{}
|
||||
err := backend.InitConfig(&service)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestSpotifyListenAsListen(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue