-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathshop_test.go
44 lines (37 loc) · 1008 Bytes
/
shop_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
package tiktok_test
import (
"context"
"testing"
"github.com/ipfans/tiktok"
"github.com/jarcoal/httpmock"
"github.com/stretchr/testify/require"
)
func TestClient_GetAuthorizedShop(t *testing.T) {
restore := mockTime()
defer restore()
tests := loadTestData(t, "testdata/shop/get_authorized_shop.json")
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
var args struct {
AppKey string `json:"app_key"`
AppSecret string `json:"app_secret"`
AccessToken string `json:"access_token"`
ShopID string `json:"shop_id"`
}
httpmock.Activate()
defer httpmock.DeactivateAndReset()
var want tiktok.ShopList
setupMock(t, tt, &args, &want)
c, err := tiktok.New(args.AppKey, args.AppSecret)
require.NoError(t, err)
shops, err := c.GetAuthorizedShop(context.TODO(), args.AccessToken, args.ShopID)
if tt.WantErr {
require.Error(t, err)
return
} else {
require.NoError(t, err)
}
require.Equal(t, want, shops)
})
}
}