-
Notifications
You must be signed in to change notification settings - Fork 15
/
auth_integ_test.go
48 lines (44 loc) · 911 Bytes
/
auth_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
//go:build integration
// +build integration
package tiktok_test
import (
"context"
"os"
"testing"
"time"
"github.com/ipfans/tiktok"
"github.com/stretchr/testify/require"
)
func TestClient_RefreshToken_Integration(t *testing.T) {
c := newTestClient(t)
RK := os.Getenv("RK")
if tiktok.CheckEmpty(RK) {
t.Skip("AK or RK is empty")
return
}
tests := []struct {
name string
rk string
wantErr require.ErrorAssertionFunc
}{
{
name: "Refresh Token with valid token",
rk: RK,
wantErr: require.NoError,
},
{
name: "Refresh Token with invalid token",
rk: RK + "111",
wantErr: require.Error,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := c.RefreshToken(context.TODO(), tt.rk)
tt.wantErr(t, err)
if err == nil {
require.Greater(t, got.RefreshTokenExpireIn, int(time.Now().Unix()))
}
})
}
}