-
Notifications
You must be signed in to change notification settings - Fork 0
/
options_test.go
55 lines (51 loc) · 1.3 KB
/
options_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 dynamodbstore
import (
"testing"
"github.com/gorilla/sessions"
"github.com/stretchr/testify/require"
)
func TestSessionOptions(t *testing.T) {
assert := require.New(t)
type args struct {
opts []Option
}
tests := []struct {
name string
args args
want *StoreOptions
}{
{
name: "should update tablename",
args: args{opts: []Option{TableName("testing")}},
want: &StoreOptions{tableName: "testing"},
},
{
name: "should update tablename and max age",
args: args{opts: []Option{TableName("testing"), DefaultMaxAge(3600)}},
want: &StoreOptions{tableName: "testing", defaultMaxAge: 3600},
},
{
name: "should update tablename and session options",
args: args{opts: []Option{TableName("testing"), SessionOptions(&sessions.Options{
HttpOnly: true,
})}},
want: &StoreOptions{tableName: "testing", sessionOptions: &sessions.Options{
HttpOnly: true,
}},
},
{
name: "should update tablename and key pairs",
args: args{opts: []Option{TableName("testing"), KeyPairs([]byte("hello"))}},
want: &StoreOptions{tableName: "testing", keyPairs: [][]byte{[]byte("hello")}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
so := &StoreOptions{}
for _, opt := range tt.args.opts {
opt(so)
}
assert.Equal(tt.want, so)
})
}
}