-
Notifications
You must be signed in to change notification settings - Fork 15
/
reverseorder_integ_test.go
170 lines (163 loc) · 3.9 KB
/
reverseorder_integ_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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//go:build integration
package tiktok_test
import (
"context"
"encoding/json"
"os"
"testing"
"github.com/ipfans/tiktok"
"github.com/stretchr/testify/require"
)
func TestClient_ConfirmReverse_Integration(t *testing.T) {
c := newTestClient(t)
type args struct {
ak string
shopID string
query string
}
tests := []struct {
name string
args args
wantList string
wantErr bool
}{
{
name: " ConfirmReverse Integration Test ",
args: args{
ak: os.Getenv(_AK_KEY),
shopID: os.Getenv(_SHOP_KEY),
query: "",
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := c.ConfirmReverse(context.TODO(), tiktok.Param{AccessToken: tt.args.ak, ShopID: tt.args.shopID}, tt.args.query)
require.Equal(t, tt.wantErr, err != nil, "Client.ConfirmReverse() error = %v, wantErr %v", err, tt.wantErr)
if err != nil {
return
}
})
}
}
func TestClient_RejectReverse_Integration(t *testing.T) {
c := newTestClient(t)
type args struct {
ak string
shopID string
query tiktok.RejectReverseRequest
}
tests := []struct {
name string
args args
wantList string
wantErr bool
}{
{
name: " RejectReverse Integration Test ",
args: args{
ak: os.Getenv(_AK_KEY),
shopID: os.Getenv(_SHOP_KEY),
query: tiktok.RejectReverseRequest{
ReverseOrderID: "576505358041058167",
ReverseRejectReasonKey: "reverse_reject_request_reason_1",
ReverseRejectComments: "Please return it ya",
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := c.RejectReverse(context.TODO(), tiktok.Param{AccessToken: tt.args.ak, ShopID: tt.args.shopID}, tt.args.query)
require.Equal(t, tt.wantErr, err != nil, "Client.RejectReverse() error = %v, wantErr %v", err, tt.wantErr)
if err != nil {
return
}
})
}
}
func TestClient_GetReverseList_Integration(t *testing.T) {
c := newTestClient(t)
type args struct {
ak string
shopID string
query tiktok.GetReverseListRequest
}
tests := []struct {
name string
args args
wantList string
wantErr bool
}{
{
name: " GetReverseList Integration Test ",
args: args{
ak: os.Getenv(_AK_KEY),
shopID: os.Getenv(_SHOP_KEY),
query: tiktok.GetReverseListRequest{
Offset: 1,
Size: _PAGESIZE,
UpdateTimeTo: 1671224452,
UpdateTimeFrom: 1558152466,
ReverseType: 3,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ans, err := c.GetReverseList(context.TODO(), tiktok.Param{AccessToken: tt.args.ak, ShopID: tt.args.shopID}, tt.args.query)
require.Equal(t, tt.wantErr, err != nil, "Client.GetReverseList() error = %v, wantErr %v", err, tt.wantErr)
if err != nil {
return
}
require.Empty(t, ans)
b, _ := json.Marshal(ans)
jsonData := string(b)
t.Log(jsonData)
})
}
}
func TestClient_GetReverseReason_Integration(t *testing.T) {
c := newTestClient(t)
type args struct {
ak string
shopID string
query tiktok.GetReverseReasonRequest
}
tests := []struct {
name string
args args
wantList string
wantErr bool
}{
{
name: " GetReverseReason Integration Test ",
args: args{
ak: os.Getenv(_AK_KEY),
shopID: os.Getenv(_SHOP_KEY),
query: tiktok.GetReverseReasonRequest{
ReasonType: 1,
ReverseActionType: 1,
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ans, err := c.GetReverseReason(context.TODO(), tiktok.Param{AccessToken: tt.args.ak, ShopID: tt.args.shopID}, tt.args.query)
require.Equal(t, tt.wantErr, err != nil, "Client.GetReverseReason() error = %v, wantErr %v", err, tt.wantErr)
if err != nil {
return
}
require.NotEmpty(t, ans)
b, _ := json.Marshal(ans)
jsonData := string(b)
t.Log(jsonData)
})
}
}