forked from kevinburke/twilio-go
-
Notifications
You must be signed in to change notification settings - Fork 1
/
verify_test.go
88 lines (81 loc) · 2.44 KB
/
verify_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
79
80
81
82
83
84
85
86
87
88
package twilio
import (
"context"
"net/url"
"testing"
)
func TestVerifyPhoneNumbersCreate(t *testing.T) {
t.Parallel()
client, s := getServer(verifyResponse)
defer s.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
data := url.Values{}
data.Add("to", "+14155551234")
data.Add("channel", "sms")
verify, err := client.Verify.Verifications.Create(ctx, "VA9e0bd45bfa7d9b9e7dca86cf94c7d4f8", data)
if err != nil {
t.Fatal(err)
}
if verify.To != "+14155551234" {
t.Errorf("expected To to be %s, got %s", "+14155551234", verify.To)
}
if verify.Valid {
t.Errorf("expected Valid to be %t, got %t", false, true)
}
if verify.Channel != "sms" {
t.Errorf("expected Channel to be %s, got %s", "sms", verify.Channel)
}
if verify.Lookup.Carrier.Type != "mobile" {
t.Errorf("expected Lookup.Carrier to be %s, got %s", "mobile", verify.Lookup.Carrier.Type)
}
}
func TestVerifyPhoneNumbersGet(t *testing.T) {
t.Parallel()
client, s := getServer(verifyResponse)
defer s.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
verify, err := client.Verify.Verifications.Get(ctx, "VA9e0bd45bfa7d9b9e7dca86cf94c7d4f8", "+14155551234")
if err != nil {
t.Fatal(err)
}
if verify.To != "+14155551234" {
t.Errorf("expected To to be %s, got %s", "+14155551234", verify.To)
}
if verify.Valid {
t.Errorf("expected Valid to be %t, got %t", false, true)
}
if verify.Channel != "sms" {
t.Errorf("expected Channel to be %s, got %s", "sms", verify.Channel)
}
if verify.Lookup.Carrier.Type != "mobile" {
t.Errorf("expected Lookup.Carrier to be %s, got %s", "mobile", verify.Lookup.Carrier.Type)
}
}
func TestVerifyPhoneNumbersCheck(t *testing.T) {
t.Parallel()
client, s := getServer(verifyCheckResponse)
defer s.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
data := url.Values{}
data.Add("code", "1234")
data.Add("to", "+14155551234")
verify, err := client.Verify.Verifications.Check(ctx, "VA9e0bd45bfa7d9b9e7dca86cf94c7d4f8", data)
if err != nil {
t.Fatal(err)
}
if verify.To != "+14155551234" {
t.Errorf("expected To to be %s, got %s", "+14155551234", verify.To)
}
if !verify.Valid {
t.Errorf("expected Valid to be %t, got %t", true, false)
}
if verify.Status != "approved" {
t.Errorf("expected Status to be %s, got %s", "approved", verify.Status)
}
if verify.Channel != "sms" {
t.Errorf("expected Channel to be %s, got %s", "sms", verify.Channel)
}
}