-
Notifications
You must be signed in to change notification settings - Fork 15
/
shop_integ_test.go
58 lines (54 loc) · 1.09 KB
/
shop_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
//go:build integration
// +build integration
package tiktok_test
import (
"context"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestClient_GetAuthorizedShop_Integration(t *testing.T) {
c := newTestClient(t)
type args struct {
ak string
shop_id string
}
tests := []struct {
name string
args args
wantShops string
wantErr bool
}{
{
name: "Request with ak",
args: args{
ak: os.Getenv("AK"),
},
wantShops: os.Getenv("SHOP"),
wantErr: false,
},
{
name: "Request with invalid ak",
args: args{
ak: os.Getenv("AK") + "111",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotShops, err := c.GetAuthorizedShop(context.TODO(), tt.args.ak, tt.args.shop_id)
require.Equal(t, tt.wantErr, err != nil, "Client.GetAuthorizedShop() error = %v, wantErr %v", err, tt.wantErr)
if err != nil {
return
}
contains := false
for i := range gotShops.Shops {
if gotShops.Shops[i].ShopID == tt.wantShops {
contains = true
}
}
require.True(t, contains)
})
}
}