This repository has been archived by the owner on Nov 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtm_auth_test.go
72 lines (62 loc) · 1.64 KB
/
rtm_auth_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
package rtm
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestAuth(t *testing.T) {
t.Run("CheckToken", func(t *testing.T) {
expected := &AuthInfo{
Token: "XXX",
Perms: "delete",
User: AuthInfoUser{
ID: "6561679",
UserName: "alexey.tester",
FullName: "Alexey Tester",
},
}
t.Run("Unmarshal", func(t *testing.T) {
b := readTestdataFile(t, "rtm.auth.checkToken.json")
actual, err := new(Client).Auth().checkTokenUnmarshal(b)
require.NoError(t, err)
assert.Equal(t, expected, actual)
})
t.Run("Real", func(t *testing.T) {
actual, err := GetClient(t).Auth().CheckToken(Ctx)
require.NoError(t, err)
actual.Token = "XXX"
assert.Equal(t, expected, actual)
})
})
t.Run("GetFrob", func(t *testing.T) {
expected := "XXX"
t.Run("Unmarshal", func(t *testing.T) {
b := readTestdataFile(t, "rtm.auth.getFrob.json")
actual, err := new(Client).Auth().getFrobUnmarshal(b)
require.NoError(t, err)
assert.Equal(t, expected, actual)
})
t.Run("Real", func(t *testing.T) {
actual, err := GetClient(t).Auth().GetFrob(Ctx)
require.NoError(t, err)
assert.NotEmpty(t, actual)
})
})
t.Run("GetToken", func(t *testing.T) {
expected := &AuthInfo{
Token: "XXX",
Perms: "delete",
User: AuthInfoUser{
ID: "6561679",
UserName: "alexey.tester",
FullName: "Alexey Tester",
},
}
t.Run("Unmarshal", func(t *testing.T) {
b := readTestdataFile(t, "rtm.auth.getToken.json")
actual, err := new(Client).Auth().getTokenUnmarshal(b)
require.NoError(t, err)
assert.Equal(t, expected, actual)
})
})
}