-
Notifications
You must be signed in to change notification settings - Fork 2
/
storage_test.go
43 lines (31 loc) · 893 Bytes
/
storage_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
package appserver
import (
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/oauth2"
)
func TestTokenStore_Store(t *testing.T) {
store := newTokenStore()
token := &oauth2.Token{AccessToken: "accesstoken"}
store.Store("shopA", token)
assert.Len(t, store.accessTokens, 1)
assert.Equal(t, token, store.accessTokens["shopA"])
newToken := &oauth2.Token{AccessToken: "newtoken"}
store.Store("shopA", newToken)
assert.Len(t, store.accessTokens, 1)
assert.Equal(t, newToken, store.accessTokens["shopA"])
}
func TestTokenStore_Get(t *testing.T) {
store := newTokenStore()
token := &oauth2.Token{AccessToken: "accesstoken"}
store.Store("shopA", token)
assert.Len(t, store.accessTokens, 1)
tk, ok := store.Get("shopA")
if assert.True(t, ok) {
assert.NotNil(t, tk)
assert.Equal(t, token, tk)
}
// get unknown
_, ok = store.Get("foo")
assert.False(t, ok)
}