-
Notifications
You must be signed in to change notification settings - Fork 3
/
loader_test.go
46 lines (36 loc) · 886 Bytes
/
loader_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
package conf
import (
"os"
"testing"
)
func TestLoader_Load(t *testing.T) {
l := NewLoader()
c, err := l.Env().Defaults(map[string]interface{}{"foo": "bar"}).Load()
if err != nil {
t.Fatalf("err should be nil, but it's %s", err)
}
v := c.String("foo")
if v != "bar" {
t.Errorf("the value of foo should be bar, but it's %v", v)
}
os.Setenv("foo", "baz")
c, err = l.Env().Defaults(map[string]interface{}{"foo": "bar"}).Load()
if err != nil {
t.Fatalf("err should be nil, but it's %s", err)
}
v = c.String("foo")
if v != "baz" {
t.Errorf("the value of foo should be baz, but it's %v", v)
}
}
func TestLoader_AdapterList(t *testing.T) {
s := adapterList{make([]Adapter, 0)}
r := s.Add(file{"path"})
if !r {
t.Errorf("should be able to add a new adapter")
}
r = s.Add(file{"path"})
if r {
t.Errorf("shouldn't be able to add another adapter")
}
}