forked from plivo/plivo-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_test.go
49 lines (39 loc) · 998 Bytes
/
media_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package plivo
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
func TestMedia_List(t *testing.T) {
expectResponse("MediaListResponse.json", 200)
if _, err := client.Media.List(MediaListParams{Limit: 0, Offset: 20}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Media.List(MediaListParams{Limit: 0, Offset: 20})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "Media")
}
func TestMedia_Get(t *testing.T) {
expectResponse("MediaGetResponse.json", 200)
MediaID := "MediaID"
media, err := client.Media.Get(MediaID)
assert.Equal(t, MediaID, media.MediaID)
if err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err = client.Media.Get(MediaID)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "Media/%s", MediaID)
}