-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
85 lines (67 loc) · 2.09 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
package singularity
import "testing"
//TODO: move this file when config.go is moved
//TestConfigCheckBoolNotExistsReturnsFalse test
func TestConfigCheckBool(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
v, ok := config.CheckBool("does_not_exist")
if v != false {
t.Error("Expected value of false, got ", v)
}
if ok != false {
t.Error("Expected ok of false, got ", v)
}
}
//TestConfigCheckBoolExistsReturnsTrue test
func TestConfigCheckBoolExistsReturnsTrue(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
config.config["item"] = true
v, ok := config.CheckBool("item")
if v != true {
t.Error("Expected value of true, got ", v)
}
if ok != true {
t.Error("Expected ok of true, got ", v)
}
}
//TestConfigGetBoolExistsReturnsTrue test
func TestConfigGetBoolExistsReturnsTrue(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
config.config["item"] = true
v := config.GetBool("item")
if v != true {
t.Error("Expected value of true, got ", v)
}
}
//TestConfigCheckStringDoesNotExistsReturnsFalse test
func TestConfigCheckStringDoesNotExistsReturnsFalse(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
v, ok := config.CheckString("item")
if v != "" {
t.Error("Expected value of 'item-value', got ", v)
}
if ok != false {
t.Error("Expected ok of false, got ", v)
}
}
//TestConfigCheckStringExistsReturnsTrue test
func TestConfigCheckStringExistsReturnsTrue(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
config.config["item"] = "item-value"
v, ok := config.CheckString("item")
if v != "item-value" {
t.Error("Expected value of 'item-value', got ", v)
}
if ok != true {
t.Error("Expected ok of true, got ", v)
}
}
//TestConfigGetStringExistsReturnsTrue test
func TestConfigGetStringExistsReturnsTrue(t *testing.T) {
config := &defaultConfig{config: make(map[string]interface{})}
config.config["item"] = "item-value"
v := config.GetString("item")
if v != "item-value" {
t.Error("Expected value of 'item-value', got ", v)
}
}