This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
incoming_phone_number_test.go
65 lines (49 loc) · 1.74 KB
/
incoming_phone_number_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
package twiliogo
import (
"encoding/json"
"net/url"
"testing"
"github.com/stretchr/testify/assert"
)
var testNumber = IncomingPhoneNumber{
Sid: "testsid",
AccountSid: "AC3TestAccount",
FriendlyName: "testname",
PhoneNumber: "+1 (444) 444-4444",
VoiceUrl: "http://test.com",
VoiceMethod: "POST",
VoiceFallbackUrl: "http://fail.com",
VoiceFallbackMethod: "GET",
VoiceCallerIdLookup: true,
StatusCallback: "http://status.com",
StatusCallbackMethod: "GET",
SmsUrl: "http://sms.com",
SmsMethod: "GET",
DateCreated: "2013-05-11",
DateUpdated: "2013-05-11",
Capabilities: Capabilites{true, true, true},
ApiVersion: "2008-04-01",
Uri: "/2010-04-01/Accounts/AC3TestAccount/Messages/testsid.json",
}
func TestBuyPhoneNumber(t *testing.T) {
client := new(MockClient)
numberJson, _ := json.Marshal(testNumber)
params := url.Values{}
params.Set("PhoneNumber", "4444444444")
client.On("post", params, "/IncomingPhoneNumbers.json").Return(numberJson, nil)
number, err := BuyPhoneNumber(client, PhoneNumber("4444444444"))
client.Mock.AssertExpectations(t)
if assert.Nil(t, err, "Error unmarshaling number") {
assert.Equal(t, number.Sid, "testsid", "Number malformed")
}
}
func TestGetIncomingPhoneNumber(t *testing.T) {
client := new(MockClient)
numberJson, _ := json.Marshal(testNumber)
client.On("get", url.Values{}, "/IncomingPhoneNumbers/testsid.json").Return(numberJson, nil)
number, err := GetIncomingPhoneNumber(client, "testsid")
client.Mock.AssertExpectations(t)
if assert.Nil(t, err, "Error unmarshaling number") {
assert.Equal(t, number.Sid, "testsid", "Number malformed")
}
}