-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder_test.go
95 lines (85 loc) · 1.72 KB
/
builder_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
package configurationmanager
import (
"testing"
"github.com/andreasisnes/go-configuration-manager/modules"
"github.com/stretchr/testify/assert"
)
func TestBuilderNew(t *testing.T) {
RunTests(t, &[]Test{
{
name: "should return non nil value",
run: func(t *testing.T) {
builder := New(nil)
assert.NotNil(t, builder)
assert.NotNil(t, builder.Modules())
},
},
})
}
func TestBuilderAdd(t *testing.T) {
RunTests(t, &[]Test{
{
name: "given nil argument should not be added",
run: func(t *testing.T) {
builder := builder{
modules: []modules.Module{},
}
builder.Add(nil)
assert.Empty(t, builder.modules)
},
},
{
name: "given non nil argument should be added to list",
run: func(t *testing.T) {
builder := builder{
modules: []modules.Module{},
}
builder.Add(&testModule{})
builder.Add(&testModule{})
assert.Len(t, builder.modules, 2)
},
},
})
}
func TestBuilderClear(t *testing.T) {
RunTests(t, &[]Test{
{
name: "should create a new list",
run: func(t *testing.T) {
builder := builder{
modules: []modules.Module{},
}
builder.Add(&testModule{})
builder.Clear()
assert.Empty(t, builder.modules)
},
},
})
}
func TestBuilderModules(t *testing.T) {
RunTests(t, &[]Test{
{
name: "should return list of modules",
run: func(t *testing.T) {
builder := builder{
modules: []modules.Module{
&testModule{},
},
}
assert.Len(t, builder.Modules(), 1)
},
},
})
}
func TestBuilderBuild(t *testing.T) {
RunTests(t, &[]Test{
{
name: "should return a configuration instance",
run: func(t *testing.T) {
config := New(nil).
Build()
assert.NotNil(t, config)
},
},
})
}