-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken_store_option_test.go
55 lines (47 loc) · 1.19 KB
/
token_store_option_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
package hcstore
import (
"context"
"testing"
"github.com/hazelcast/hazelcast-go-client"
)
func TestHCTokenStoreOptions(t *testing.T) {
type test struct {
name string
options []TokenStoreOption
willError bool
}
table := []test{
{
name: "empty map names",
options: []TokenStoreOption{WithAccessMapName(""), WithCodesMapName(""), WithRefreshMapName("")},
willError: true,
},
{
name: "some empty names",
options: []TokenStoreOption{WithAccessMapName("am"), WithCodesMapName(""), WithRefreshMapName("rm")},
willError: true,
},
{
name: "filled map names",
options: []TokenStoreOption{WithAccessMapName("am"), WithCodesMapName("cm"), WithRefreshMapName("rm")},
willError: false,
},
}
ctx := context.Background()
hzClient, err := hazelcast.StartNewClient(ctx)
if err != nil {
t.Fatalf("failed to connect to hazelcast: %v", err)
}
defer hzClient.Shutdown(ctx)
for _, x := range table {
if _, err := NewTokenStore(hzClient, x.options...); err != nil {
if !x.willError {
t.Fatalf("expected to err on test %s", x.name)
}
} else {
if x.willError {
t.Fatalf("expected not to err on test %s", x.name)
}
}
}
}