-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathverify_callerid_test.go
127 lines (103 loc) · 3.35 KB
/
verify_callerid_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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package plivo
import (
"errors"
"testing"
)
func TestVerifyCallerIdService_InitiateVerify(t *testing.T) {
expectResponse("initiateVerifyResponse.json", 200)
if _, err := client.VerifyCallerId.InitiateVerify(InitiateVerify{
PhoneNumber: "917708772011",
Alias: "test",
Channel: "call",
}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.VerifyCallerId.InitiateVerify(InitiateVerify{
PhoneNumber: "917708772011",
Alias: "test",
Channel: "call",
})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "POST", "VerifiedCallerId")
}
func TestVerifyCallerIdService_VerifyCallerID(t *testing.T) {
expectResponse("verifyCallerIDResponse.json", 200)
if _, err := client.VerifyCallerId.VerifyCallerID("eeab1477-e59b-4821-9e61-fd5847c2a5db", "610534"); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.VerifyCallerId.VerifyCallerID("eeab1477-e59b-4821-9e61-fd5847c2a5db", "610534")
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "POST", "VerifiedCallerId/Verification/eeab1477-e59b-4821-9e61-fd5847c2a5db")
}
func TestVerifyCallerIdService_DeleteVerifiedCallerID(t *testing.T) {
expectResponse("", 204)
if err := client.VerifyCallerId.DeleteVerifiedCallerID("917708772010"); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
err := client.VerifyCallerId.DeleteVerifiedCallerID("917708772010")
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "DELETE", "VerifiedCallerId/917708772010")
}
func TestVerifyCallerIdService_GetVerifiedCallerID(t *testing.T) {
expectResponse("getVerifiedCallerIDResponse.json", 200)
if _, err := client.VerifyCallerId.GetVerifiedCallerID("917708772010"); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.VerifyCallerId.GetVerifiedCallerID("917708772010")
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "VerifiedCallerId/917708772010")
}
func TestVerifyCallerIdService_UpdateVerifiedCallerID(t *testing.T) {
expectResponse("updateVerifiedCallerIDResponse.json", 204)
if _, err := client.VerifyCallerId.UpdateVerifiedCallerID("917708772010", UpdateVerifiedCallerIDParams{}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.VerifyCallerId.UpdateVerifiedCallerID("917708772010", UpdateVerifiedCallerIDParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "POST", "VerifiedCallerId/917708772010")
}
func TestVerifyCallerIdService_ListVerifiedCallerID(t *testing.T) {
expectResponse("listVerifiedCallerIDResponse.json", 204)
if _, err := client.VerifyCallerId.ListVerifiedCallerID(ListVerifiedCallerIdParams{}); err != nil {
panic(err)
}
cl := client.httpClient
client.httpClient = nil
_, err := client.VerifyCallerId.ListVerifiedCallerID(ListVerifiedCallerIdParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
assertRequest(t, "GET", "VerifiedCallerId")
}