-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
110 lines (100 loc) · 3.51 KB
/
config_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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2017 Cameron Bergoon
// Licensed under the LGPLv3, see LICENCE file for details.
package stitchdb
import (
"testing"
"time"
)
func TestPersist(t *testing.T) {
config, err := NewConfig(Persist)
if err != nil {
t.Errorf("Failure: NewConfig(Persist) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(Persist) returned nil config")
}
if config.persist != true {
t.Errorf("Failure: NewConfig(Persist) expected config.persist == true got config.persist == %v", config.persist)
}
}
func TestDirPath(t *testing.T) {
config, err := NewConfig(DirPath("/path/to/dir"))
if err != nil {
t.Errorf("Failure: NewConfig(DirPath(\"/path/to/dir\")) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(DirPath(\"/path/to/dir\")) returned nil config")
}
if config.dirPath != "/path/to/dir" {
t.Errorf("Failure: NewConfig(DirPath(\"/path/to/dir\")) expected config.dirPath == \"/path/to/dir\" got config.dirPath == %v", config.dirPath)
}
}
func TestSync(t *testing.T) {
config, err := NewConfig(Sync(NONE))
if err != nil {
t.Errorf("Failure: NewConfig(Sync(NONE)) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(Sync(NONE)) returned nil config")
}
if config.syncFreq != NONE {
t.Errorf("Failure: NewConfig(Sync(NONE)) expected config.syncFreq == NONE got config.syncFreq == %v", config.syncFreq)
}
}
func TestBucketFileMultLimit(t *testing.T) {
config, err := NewConfig(BucketFileMultLimit(10))
if err != nil {
t.Errorf("Failure: NewConfig(Sync(NONE)) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(Sync(NONE)) returned nil config")
}
if config.bucketFileMultLimit != 10 {
t.Errorf("Failure: NewConfig(Sync(NONE)) expected config.bucketFileMultLimit == 10 got config.bucketFileMultLimit == %v", config.bucketFileMultLimit)
}
}
func TestManageFrequency(t *testing.T) {
config, err := NewConfig(ManageFrequency(time.Second))
if err != nil {
t.Errorf("Failure: NewConfig(ManageFrequency(time.Second)) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(ManageFrequency(time.Second)) returned nil config")
}
if config.manageFrequency != time.Second {
t.Errorf("Failure: NewConfig(ManageFrequency(time.Second)) expected config.manageFrequency == 10 got config.manageFrequency == %v", config.manageFrequency)
}
}
func TestDeveloper(t *testing.T) {
config, err := NewConfig(Developer)
if err != nil {
t.Errorf("Failure: NewConfig(Developer) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(Developer) returned nil config")
}
if config.developer != true {
t.Errorf("Failure: NewConfig(Developer) expected config.developer == true got config.developer == %v", config.developer)
}
}
func TestPerformanceMonitor(t *testing.T) {
config, err := NewConfig(PerformanceMonitor)
if err != nil {
t.Errorf("Failure: NewConfig(PerformanceMonitor) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(PerformanceMonitor) returned nil config")
}
if config.performanceMonitor != true {
t.Errorf("Failure: NewConfig(PerformanceMonitor) expected config.performanceMonitor == true got config.performanceMonitor == %v", config.performanceMonitor)
}
}
func TestNewConfig(t *testing.T) {
config, err := NewConfig(PerformanceMonitor)
if err != nil {
t.Errorf("Failure: NewConfig(PerformanceMonitor) returned error \"%v\"", err)
}
if config == nil {
t.Errorf("Failure: NewConfig(PerformanceMonitor) returned nil config")
}
}