/
mms_test.go
88 lines (68 loc) · 2.12 KB
/
mms_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
// Copyright 2017 Avaya Cloud Inc. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package zang
import (
"net/http"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestListMms(t *testing.T) {
client, err := NewClient()
Convey("New Client With Defaults", t, func() {
So(client, ShouldNotBeNil)
So(err, ShouldBeNil)
})
Convey("List mms retrieval successful", t, func() {
response, err := client.ListMms(map[string]string{
"Page": "2",
"PageSize": "1",
})
So(response, ShouldNotBeNil)
So(err, ShouldBeNil)
So(response.Response, ShouldHaveSameTypeAs, &http.Response{})
So(response.Resource, ShouldNotBeNil)
subResource := response.GetSubResource("mms_messages")
So(len(subResource), ShouldBeGreaterThanOrEqualTo, 0)
for application := range subResource {
So(subResource[application]["date_updated"], ShouldNotBeBlank)
}
})
}
func TestGetMms(t *testing.T) {
client, err := NewClient()
Convey("New Client With Defaults", t, func() {
So(client, ShouldNotBeNil)
So(err, ShouldBeNil)
})
Convey("Conference retrieval successful", t, func() {
response, err := client.GetMms("MM24b6d24c57c94c58b3d6f35e0ca9bd71")
So(err, ShouldBeNil)
So(response, ShouldNotBeNil)
So(response.Response, ShouldHaveSameTypeAs, &http.Response{})
So(response.Resource, ShouldNotBeNil)
res := response.GetSingleResource("mms_row")
So(res["mms_sid"], ShouldEqual, "MM24b6d24c57c94c58b3d6f35e0ca9bd71")
})
}
func TestSendMms(t *testing.T) {
client, err := NewClient()
Convey("New Client With Defaults", t, func() {
So(client, ShouldNotBeNil)
So(err, ShouldBeNil)
})
Convey("Send mms", t, func() {
response, err := client.SendMms(map[string]string{
"From": "+xxx",
"To": "+xxx",
"Body": "body",
"MediaUrl": "http://full-url-to-media.jpeg",
})
So(err, ShouldBeNil)
So(response, ShouldNotBeNil)
So(response.Response, ShouldHaveSameTypeAs, &http.Response{})
So(response.Resource, ShouldNotBeNil)
res := response.GetSingleResource("mms_row")
So(res["mms_sid"], ShouldNotBeEmpty)
})
}