-
Notifications
You must be signed in to change notification settings - Fork 23
/
media_test.go
45 lines (38 loc) · 1.07 KB
/
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
package plivo
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestMedia_List(t *testing.T) {
expectResponse("MediaListResponse.json", 200)
assert := require.New(t)
resp, err := client.Media.List(MediaListParams{Limit: 0, Offset: 20})
assert.NotNil(resp)
assert.Nil(err)
assert.NotEmpty(resp.Media[0].MediaID)
assert.NotNil(resp.Meta)
cl := client.httpClient
client.httpClient = nil
resp, err = client.Media.List(MediaListParams{Limit: 0, Offset: 20})
assert.NotNil(err)
assert.Nil(resp)
client.httpClient = cl
assertRequest(t, "GET", "Media")
}
func TestMedia_Get(t *testing.T) {
expectResponse("MediaGetResponse.json", 200)
MediaID := "98854bc5-ea05-4837-a301-0272523e6156"
assert := require.New(t)
media, err := client.Media.Get(MediaID)
assert.NotNil(media)
assert.Nil(err)
assert.Equal(MediaID, media.MediaID)
assert.NotEmpty(media.ContentType)
cl := client.httpClient
client.httpClient = nil
media, err = client.Media.Get(MediaID)
assert.NotNil(err)
assert.Nil(media)
client.httpClient = cl
assertRequest(t, "GET", "Media/%s", MediaID)
}