-
Notifications
You must be signed in to change notification settings - Fork 23
/
recordings_test.go
67 lines (55 loc) · 1.47 KB
/
recordings_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package plivo
import (
"errors"
"github.com/stretchr/testify/assert"
"testing"
)
func TestRecordingService_List(t *testing.T) {
expectResponse("RecordingListResponse.json", 200)
if _, err := client.Recordings.List(RecordingListParams{}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.Recordings.List(RecordingListParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "Recording")
}
func TestRecordingService_Get(t *testing.T) {
expectResponse("RecordingGetResponse.json", 200)
RecordingId := "RecordingId"
recording, err := client.Recordings.Get(RecordingId)
assert.Equal(t, recording.ID(), recording.RecordingID)
if err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err = client.Recordings.Get(RecordingId)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "Recording/%s", RecordingId)
}
func TestRecordingService_Delete(t *testing.T) {
expectResponse("", 204)
RecordingId := "RecordingId"
if err := client.Recordings.Delete(RecordingId); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
err := client.Recordings.Delete(RecordingId)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "DELETE", "Recording/%s", RecordingId)
}