-
Notifications
You must be signed in to change notification settings - Fork 0
/
goconfig_test.go
59 lines (48 loc) · 995 Bytes
/
goconfig_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
package goconfig
import
(
"testing"
)
type Example struct{
Data int
Name string
}
func TestLoadJSON(t *testing.T) {
exp := Example{}
res := Load("./testdata/test1.json", &exp)
if res != nil {
t.Error("File not found")
}
if exp.Data != 10 {
t.Errorf("Expected %d, found %d", 10, exp.Data)
}
if exp.Name != "doom" {
t.Errorf("Expected %s, found %s", "doom", exp.Name)
}
}
func TestLoadYAML(t *testing.T) {
exp := Example{}
res := Load("./testdata/test1.yaml", &exp)
if res != nil {
t.Error("File not found")
}
if exp.Data != 10 {
t.Errorf("Expected %d, found %d", 10, exp.Data)
}
if exp.Name != "Doom" {
t.Errorf("Expected %s, found %s", "Doom", exp.Name)
}
}
func TestLoadHCL(t *testing.T) {
exp := Example{}
res := Load("./testdata/test1.hcl", &exp)
if res != nil {
t.Error("File not found")
}
if exp.Data != 7 {
t.Errorf("Expected %d, found %d", 7, exp.Data)
}
if exp.Name != "bar" {
t.Errorf("Expected %s, found %s", "bar", exp.Name)
}
}