-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.go
65 lines (49 loc) · 1.04 KB
/
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
package configurationmanager
import (
"testing"
"github.com/andreasisnes/go-configuration-manager/modules"
)
type Test struct {
name string
run func(t *testing.T)
}
func RunTests(t *testing.T, tests *[]Test) {
for _, test := range *tests {
t.Run(test.name, test.run)
}
}
func newTestModule(options *modules.Options, opts ...func(map[string]any)) *testModule {
if options == nil {
options = &modules.Options{}
}
t := &testModule{
values: make(map[string]any),
ModuleBase: modules.NewSourceBase(options),
}
for _, opt := range opts {
opt(t.values)
opt(t.Flatmap)
}
return t
}
type testModule struct {
*modules.ModuleBase
values map[string]any
}
func (module *testModule) GetRefreshedValue(key string) any {
return nil
}
func (module *testModule) Deconstruct() {
}
func (module *testModule) Load() {
}
func (module *testModule) Exists(key string) bool {
_, ok := module.values[key]
return ok
}
func (module *testModule) Get(key string) any {
if val, ok := module.values[key]; ok {
return val
}
return nil
}