/
usage_test.go
60 lines (46 loc) · 1.46 KB
/
usage_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
// 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 TestListUsages(t *testing.T) {
client, err := NewClient()
Convey("New Client With Defaults", t, func() {
So(client, ShouldNotBeNil)
So(err, ShouldBeNil)
})
Convey("List usages retrieval successful", t, func() {
response, err := client.ListUsages(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("usages")
So(len(subResource), ShouldBeGreaterThanOrEqualTo, 0)
for usage := range subResource {
So(subResource[usage]["date_updated"], ShouldNotBeBlank)
}
})
}
func TestGetUsage(t *testing.T) {
client, err := NewClient()
Convey("New Client With Defaults", t, func() {
So(client, ShouldNotBeNil)
So(err, ShouldBeNil)
})
Convey("Usage retrieval successful", t, func() {
response, err := client.GetUsage("AU24b6d24c57c94c58b3d6f35e0ca9bd71")
So(err, ShouldBeNil)
So(response, ShouldNotBeNil)
So(response.Response, ShouldHaveSameTypeAs, &http.Response{})
So(response.Resource, ShouldNotBeNil)
So(response.Resource["sid"], ShouldEqual, "AUO07889084c63ecd8c3c3f49c7b552ba6f")
})
}