forked from kevinburke/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify_credentials_test.go
78 lines (61 loc) · 1.75 KB
/
notify_credentials_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
68
69
70
71
72
73
74
75
76
77
78
package twilio
import (
"context"
"net/url"
"testing"
)
func TestNotifyCredentialsGetPage(t *testing.T) {
t.Parallel()
client, server := getServer(credentialsPage)
defer server.Close()
page, err := client.Notify.Credentials.GetPage(context.Background(), url.Values{})
if err != nil {
t.Fatal(err)
}
if len(page.Credentials) != 2 {
t.Fatalf("expected len(credentials) to be 2, got %d", len(page.Credentials))
}
}
func TestNotifyCredentialsGet(t *testing.T) {
t.Parallel()
client, server := getServer(notifyCredential)
defer server.Close()
cred, err := client.Notify.Credentials.Get(context.Background(), "123")
if err != nil {
t.Fatal(err)
}
expected := "AC6bc21af903cc765a9d7f7e0467ec812a"
if cred.AccountSid != expected {
t.Errorf("expected AccountSid to be %s, got %s", expected, cred.Sid)
}
expected = "MyFCMCredential"
if cred.FriendlyName != expected {
t.Errorf("expected FriendlyName to be %s, got %s", expected, cred.FriendlyName)
}
expected = string(TypeFCM)
if cred.Type != TypeFCM {
t.Errorf("expected Type to be %s, got %s", expected, cred.Type)
}
}
func TestCreateNotifyCredentials(t *testing.T) {
if testing.Short() {
t.Skip("skipping HTTP request in short mode")
}
values := url.Values{}
values.Set("FriendlyName", "Test FCM cred")
values.Set("Type", string(TypeFCM))
values.Set("Secret", "secret here")
cred, err := envClient.Notify.Credentials.Create(context.Background(), values)
if err != nil {
t.Fatal(err)
}
if cred.Sid == "" {
t.Error("Sid should not be empty")
}
if cred.AccountSid != envClient.AccountSid {
t.Errorf("expected AccountSid to be %s, got %s", envClient.AccountSid, cred.AccountSid)
}
if cred.Type != TypeFCM {
t.Errorf("expected Type to be %s, got %s", TypeFCM, cred.Type)
}
}