forked from carlosdp/twiliogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
call_integration_test.go
65 lines (45 loc) · 1.47 KB
/
call_integration_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
package twiliogo
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIntegrationCallList(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
callList, err := GetCallList(client)
if assert.Nil(t, err, "Failed to retrieve call list") {
calls := callList.GetCalls()
assert.NotNil(t, calls, "Failed to retrieve calls")
}
}
func TestIntegrationMakingCall(t *testing.T) {
CheckTestEnv(t)
client := NewClient(TEST_KEY, TEST_TOKEN)
call, err := NewCall(client, TEST_FROM_NUMBER, TO_NUMBER, Callback("http://test.com"))
if assert.Nil(t, err, "Failed to make call") {
assert.Equal(t, call.Status, "queued", "Making Call failed, status: "+call.Status)
}
}
func TestIntegrationCallListNextPage(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
callList, err := GetCallList(client)
if assert.Nil(t, err, "Failed to retrieve call list") {
nextPageCallList, err := callList.NextPage()
if assert.Nil(t, err, "Failed to retrieve next page") {
assert.Equal(t, nextPageCallList.Page, 1, "Page incorrect on next page")
}
}
}
func TestIntegrationGetCall(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
callList, err := GetCallList(client)
if assert.Nil(t, err, "Failed to retrieve call list") {
callSid := callList.Calls[0].Sid
call, err := GetCall(client, callSid)
if assert.Nil(t, err, "Failed to retrieve call") {
assert.Equal(t, call.Sid, callSid, "Call was invalid")
}
}
}