-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig_test.go
More file actions
35 lines (29 loc) · 699 Bytes
/
config_test.go
File metadata and controls
35 lines (29 loc) · 699 Bytes
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
package dcc
import "testing"
func TestLoadConfig(t *testing.T) {
cfg, err := LoadConfig("./test/config.json")
if err != nil {
t.Error("error loading valid config")
}
if len(cfg.Locomotives) != 3 {
t.Error("config not parsed correctly")
}
_, err = LoadConfig("non-existent.json")
if err == nil {
t.Error("should have returned an error")
}
_, err = LoadConfig("./test/bad-config.json")
if err == nil {
t.Error("should have returned an error parsing")
}
}
func TestSave(t *testing.T) {
cfg, err := LoadConfig("./test/config.json")
if err != nil {
t.Fatal("cannot load config")
}
err = cfg.Save("./test/config.json")
if err != nil {
t.Error("error saving config")
}
}