-
Notifications
You must be signed in to change notification settings - Fork 0
/
option_test.go
57 lines (51 loc) · 1.21 KB
/
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
56
57
package boltutil
import (
"os"
"reflect"
"testing"
"time"
"go.etcd.io/bbolt"
)
func TestWithOption(t *testing.T) {
want := &innerOption{
FileMode: 0600,
DefaultCoder: XmlCoder{},
Options: &bbolt.Options{
Timeout: time.Second,
NoGrowSync: true,
NoFreelistSync: true,
FreelistType: bbolt.FreelistArrayType,
ReadOnly: true,
MmapFlags: 1,
InitialMmapSize: 1,
PageSize: 1,
NoSync: true,
OpenFile: nil,
},
}
options := []Option{
WithFileMode(want.FileMode),
WithDefaultCoder(want.DefaultCoder),
WithTimeout(want.Options.Timeout),
WithNoGrowSync(want.Options.NoGrowSync),
WithNoFreelistSync(want.Options.NoFreelistSync),
WithFreelistType(want.Options.FreelistType),
WithReadOnly(want.Options.ReadOnly),
WithMmapFlags(want.Options.MmapFlags),
WithInitialMmapSize(want.Options.InitialMmapSize),
WithPageSize(want.Options.PageSize),
WithNoSync(want.Options.NoSync),
WithOpenFile(want.Options.OpenFile),
}
got := &innerOption{
Options: &bbolt.Options{
OpenFile: os.OpenFile,
},
}
for _, v := range options {
v(got)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("got %+v, want %+v", got, want)
}
}