-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmsgwclient_test.go
36 lines (28 loc) · 1.07 KB
/
smsgwclient_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
package smsgwclient_test
import (
"testing"
"github.com/intelecom/smsgw-client-go"
"github.com/jarcoal/httpmock"
)
func TestErrorIsNilWhenOkResponse(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("POST", "https://www.dummy-address.com/sendMessages",
httpmock.NewStringResponder(200, `{"batchReference":"123abc","messageStatus":[]}`))
gatewayClient := smsgwclient.MakeSmsGatewayClient("https://www.dummy-address.com", 0, "", "")
messages := []smsgwclient.Message{smsgwclient.Message{}}
if _, err := gatewayClient.Send(messages); err != nil {
t.FailNow()
}
}
func TestErrorIsNotNilWhenErrorResponse(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
httpmock.RegisterResponder("POST", "https://www.dummy-address.com/sendMessages",
httpmock.NewStringResponder(500, ""))
gatewayClient := smsgwclient.MakeSmsGatewayClient("https://www.dummy-address.com", 0, "", "")
messages := []smsgwclient.Message{smsgwclient.Message{}}
if _, err := gatewayClient.Send(messages); err == nil {
t.FailNow()
}
}