1package twiliogo 2 3import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6) 7 8func TestIntegrationCallList(t *testing.T) { 9 CheckTestEnv(t) 10 11 client := NewClient(API_KEY, API_TOKEN) 12 13 callList, err := GetCallList(client) 14 15 if assert.Nil(t, err, "Failed to retrieve call list") { 16 calls := callList.GetCalls() 17 18 assert.NotNil(t, calls, "Failed to retrieve calls") 19 } 20} 21 22func TestIntegrationMakingCall(t *testing.T) { 23 CheckTestEnv(t) 24 25 client := NewClient(TEST_KEY, TEST_TOKEN) 26 27 call, err := NewCall(client, TEST_FROM_NUMBER, TO_NUMBER, Callback("http://test.com")) 28 29 if assert.Nil(t, err, "Failed to make call") { 30 assert.Equal(t, call.Status, "queued", "Making Call failed, status: "+call.Status) 31 } 32} 33 34func TestIntegrationCallListNextPage(t *testing.T) { 35 CheckTestEnv(t) 36 37 client := NewClient(API_KEY, API_TOKEN) 38 39 callList, err := GetCallList(client) 40 41 if assert.Nil(t, err, "Failed to retrieve call list") { 42 nextPageCallList, err := callList.NextPage() 43 44 if assert.Nil(t, err, "Failed to retrieve next page") { 45 assert.Equal(t, nextPageCallList.Page, 1, "Page incorrect on next page") 46 } 47 } 48} 49 50func TestIntegrationGetCall(t *testing.T) { 51 CheckTestEnv(t) 52 53 client := NewClient(API_KEY, API_TOKEN) 54 55 callList, err := GetCallList(client) 56 57 if assert.Nil(t, err, "Failed to retrieve call list") { 58 callSid := callList.Calls[0].Sid 59 call, err := GetCall(client, callSid) 60 61 if assert.Nil(t, err, "Failed to retrieve call") { 62 assert.Equal(t, call.Sid, callSid, "Call was invalid") 63 } 64 } 65} 66