| 182 | } |
| 183 | |
| 184 | func TestPlayUriTransferPlaybackTransferError(t *testing.T) { |
| 185 | const n = "test_device_name" |
| 186 | viper.Set("spotify.device_name", n) |
| 187 | |
| 188 | m := new(mocks.Client) |
| 189 | |
| 190 | ds := []spotify.PlayerDevice{ |
| 191 | { |
| 192 | ID: "ANOTHER_TEST_ID", |
| 193 | Active: true, |
| 194 | Restricted: false, |
| 195 | Name: "another_device_name", |
| 196 | Type: "", |
| 197 | Volume: 0, |
| 198 | }, |
| 199 | { |
| 200 | ID: "TEST_ID", |
| 201 | Active: false, |
| 202 | Restricted: false, |
| 203 | Name: n, |
| 204 | Type: "", |
| 205 | Volume: 0, |
| 206 | }, |
| 207 | } |
| 208 | |
| 209 | m.On("PlayerDevices").Return(ds, nil) |
| 210 | const e = "transfer error" |
| 211 | m.On("Pause").Return(nil) |
| 212 | m.On("TransferPlayback", mock.AnythingOfType("spotify.ID"), false).Return(errors.New(e)) |
| 213 | m.On("PlayOpt", mock.AnythingOfType("*spotify.PlayOptions")).Return(nil) |
| 214 | |
| 215 | err := PlayUri(m, "foobar") |
| 216 | assert.EqualError(t, err, e) |
| 217 | } |
| 218 | |
| 219 | func TestPauseSuccess(t *testing.T) { |
| 220 | const n = "test_device_name" |