forked from carlosdp/twiliogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_integration_test.go
66 lines (47 loc) · 1.68 KB
/
message_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
66
package twiliogo
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIntegrationMessageList(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
messageList, err := GetMessageList(client)
if assert.Nil(t, err, "Failed to retrieve message list") {
messages := messageList.Messages
assert.NotNil(t, messages, "Failed to retrieve messages")
}
}
func TestIntegrationSendSMS(t *testing.T) {
/* /Messages endpoint is currently not recognized by Test Credentials */
/* CheckTestEnv(t) */
/* client := NewClient(TEST_KEY, TEST_TOKEN) */
/* message, err := NewMessage(client, TEST_FROM_NUMBER, TO_NUMBER, Body("Test Message")) */
/* if assert.Nil(t, err, "Failed to Send SMS") { */
/* assert.Equal(t, message.Status, "queued", "Sending SMS failed, status: " + message.Status) */
/* } */
t.Skip()
}
func TestIntegrationMessageListNextPage(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
messageList, err := GetMessageList(client)
if assert.Nil(t, err, "Failed to retrieve message list") {
nextPageMessageList, err := messageList.NextPage()
if assert.Nil(t, err, "Failed to retrieve message list") {
assert.Equal(t, nextPageMessageList.Page, 1, "Page incorrect on next page")
}
}
}
func TestIntegrationGetMessage(t *testing.T) {
CheckTestEnv(t)
client := NewClient(API_KEY, API_TOKEN)
messageList, err := GetMessageList(client)
if assert.Nil(t, err, "Failed to retrieve message list") {
messageSid := messageList.Messages[0].Sid
message, err := GetMessage(client, messageSid)
if assert.Nil(t, err, "Failed to retrieve message") {
assert.Equal(t, message.Sid, messageSid, "Message was invalid")
}
}
}