...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package conf
16
17 import (
18 "strings"
19 "testing"
20 )
21
22 const testConfDir = "../test/conf"
23
24 func TestLoadError(t *testing.T) {
25 _, err := Load(testConfDir + "/serve.invalid")
26 if err == nil || err.Error() != `Unsupported Config Type "invalid"` {
27 t.Errorf("Unexpected error: %s", err)
28 }
29 }
30
31 func TestLoad(t *testing.T) {
32 c, err := Load(testConfDir + "/serve.toml")
33 if err != nil {
34 t.Errorf("Failed to load config: %s", err)
35 }
36 if v := c.GetString("httpd.bind_address"); v != "0.0.0.0" {
37 t.Errorf("Unexpected value %s", v)
38 }
39 }
40
41 func TestLoadDefault(t *testing.T) {
42 _, err := Load("")
43 if err != nil && !strings.HasPrefix(err.Error(), `Config File "serve" Not Found in`) {
44 t.Errorf("Failed to load default config: %s", err)
45 }
46 }
47
View as plain text