-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsdk_test.go
111 lines (107 loc) · 2.44 KB
/
sdk_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
package soracom
import (
"bytes"
"io"
"net/http"
"testing"
)
func TestMarshals(t *testing.T) {
t.Run("ListSessionEvent", func(t *testing.T) {
testdata := `[
{
"imsi": "001050910800000",
"time": 1574853374100,
"createdTime": "2019-11-27T07:15:19.544Z",
"operatorId": "OP9999209600",
"event": "Deleted",
"ueIpAddress": "10.154.128.64",
"imei": "999916091541232",
"apn": "soracom.io",
"dns0": "100.127.0.53",
"dns1": "100.127.1.53",
"cell": {
"radioType": "lte",
"mcc": 440,
"mnc": 10,
"tac": 21,
"eci": 67387471
},
"primaryImsi": "001050910800000"
},
{
"imsi": "001050910800000",
"time": 1574838919544,
"createdTime": "2019-11-27T07:15:19.544Z",
"operatorId": "OP9999209600",
"event": "Created",
"ueIpAddress": "10.154.128.64",
"imei": "999916091541232",
"apn": "soracom.io",
"dns0": "100.127.0.53",
"dns1": "100.127.1.53",
"cell": {
"radioType": "lte",
"mcc": 440,
"mnc": 10,
"tac": 21,
"eci": 67387471
},
"primaryImsi": "001050910800000"
},
{
"imsi": "001050910800000",
"time": 1574838918340,
"createdTime": "2019-11-27T07:14:17.717Z",
"operatorId": "OP9999209600",
"event": "Deleted",
"ueIpAddress": "10.154.128.64",
"imei": "999916091541232",
"apn": "soracom.io",
"dns0": "100.127.0.53",
"dns1": "100.127.1.53",
"cell": {
"radioType": "lte",
"mcc": 440,
"mnc": 10,
"tac": 21,
"eci": 67387471
},
"primaryImsi": "001050910800000"
},
{
"imsi": "001050910800000",
"time": 1574838857717,
"createdTime": "2019-11-27T07:14:17.717Z",
"operatorId": "OP9999209600",
"event": "Created",
"ueIpAddress": "10.154.128.64",
"imei": "999916091541232",
"apn": "soracom.io",
"dns0": "100.127.0.53",
"dns1": "100.127.1.53",
"cell": {
"radioType": "lte",
"mcc": 440,
"mnc": 10,
"tac": 21,
"eci": 67387471
},
"primaryImsi": "001050910800000"
}
]`
b := bytes.NewBufferString(testdata)
response := &http.Response{
Body: io.NopCloser(b),
}
rs, pek, err := parseListSessionEvents(response)
if err != nil {
t.Fatalf("failed to parseListSessionEvents(): %s", err)
}
if pek != nil {
t.Fatal("failed to parseListSessionEvents, should not contain pagination keys")
}
if len(rs) != 4 {
t.Fatalf("result length: want 4 got %d", len(rs))
}
})
}