-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunits_test.go
154 lines (129 loc) · 3.22 KB
/
units_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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
package ebct
import (
"encoding/json"
"github.com/davecgh/go-spew/spew"
"github.com/stretchr/testify/assert"
"testing"
)
const UnitAsync = `{
"dispatchNumber": 953,
"originCountry": "BR",
"originOperatorName": "FOXB",
"destinationOperatorName": "SAOD",
"postalCategoryCode": "A",
"serviceSubclassCode": "NX",
"unitList": [
{
"sequence": 1,
"unitType": 1,
"trackingNumbers": [
"NX006288545BR"
]
},
{
"sequence": 2,
"unitType": 1,
"trackingNumbers": [
"NX005475538BR"
]
}
]
}`
const Unit = `{
"dispatchNumber": 61523,
"originCountry": "CN",
"originOperatorName": "FOXB",
"destinationOperatorName": "SAOD",
"postalCategoryCode": "A",
"serviceSubclassCode": "NX",
"unitList": [
{
"sequence": 1,
"unitType": 1,
"trackingNumbers": [
"NX000823744BR"
]
}
]
}`
const UnitCodes = `{
"originCountry": "CN",
"postalCategoryCode": "A",
"serviceSubclassCode": "NL",
"unitType": 1,
"quantity": 1
}`
func TestUnitAsyncRequest(t *testing.T) {
aUnitAsync := &UnitsRequestAsync{}
var bPack = []byte(UnitAsync)
var err error
err = json.Unmarshal(bPack, aUnitAsync)
if err != nil {
spew.Dump(err)
}
packList, err := client.PostUnitsRequestAsync(aUnitAsync)
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitRequest(t *testing.T) {
aUnitAsync := &UnitsRequestAsync{}
var bPack = []byte(Unit)
var err error
err = json.Unmarshal(bPack, aUnitAsync)
if err != nil {
spew.Dump(err)
}
var packList *UnitsRequestReturn
//for i := 1; i < 999999; i++ {
// aUnitAsync.DispatchNumber = IntPtr(i)
packList, err = client.PostUnitsRequest(aUnitAsync)
// if err == nil {
// break
// }
//}
spew.Dump(packList)
assert.NoError(t, err)
spew.Dump(aUnitAsync)
}
func TestUnitAsyncGetRequest(t *testing.T) {
packList, err := client.GetUnitsRequestAsync("7d607b7b-9848-41b1-a07b-7b9848e1b115")
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitsCodesGetRequest(t *testing.T) {
packList, err := client.GetUnitsCodesRequest()
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitCodesRequest(t *testing.T) {
stUnitCodes := &UnitCodeRequest{}
var bPack = []byte(UnitCodes)
var err error
err = json.Unmarshal(bPack, stUnitCodes)
if err != nil {
spew.Dump(err)
}
packList, err := client.PostUnitCodesRequest(stUnitCodes)
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitsCodesSingleRequestGet(t *testing.T) {
packList, err := client.GetUnitsCodesSingleRequest("618a70b021a8bc472dd69abd")
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitsRequestGet(t *testing.T) {
packList, err := client.GetUnitsRequest(953)
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitsRequestDelete(t *testing.T) {
packList, err := client.DeleteUnitsCodesRequest("BRFOXBBRSAODANX20953001000001")
spew.Dump(packList)
assert.NoError(t, err)
}
func TestUnitsDispatchDelete(t *testing.T) {
packList, err := client.DeleteUnitsDispatchRequest("USDASDBRDDDDDIX00321001000024")
spew.Dump(packList)
assert.NoError(t, err)
}