-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
56 lines (49 loc) · 1018 Bytes
/
main_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
package main
import (
"testing"
"gopkg.in/ini.v1"
)
func TestDefaultConf(t *testing.T) {
cfg, err := ini.Load("assets/rtfd.cfg")
if err != nil {
t.Fatalf("Fail to read file: %v", err)
}
cfg.BlockMode = false
// 默认分区
dftSec := cfg.Section(ini.DefaultSection)
if !dftSec.HasKey("base_dir") {
t.Fatal("no base_dir")
}
ngxSec := cfg.Section("nginx")
if !ngxSec.HasKey("dn") {
t.Fatal("no nginx.dn")
}
if !ngxSec.HasKey("exec") {
t.Fatal("no nginx.exec")
}
ssl := ngxSec.Key("ssl").MustBool()
if ssl != false {
t.Fatal("the nginx.ssl should be off")
}
pySec := cfg.Section("py")
if !pySec.HasKey("py2") {
t.Fatal("no py2")
}
if !pySec.HasKey("py3") {
t.Fatal("no py3")
}
apiSec := cfg.Section("api")
if !apiSec.HasKey("host") {
t.Fatal("no api.host")
}
if !apiSec.HasKey("port") {
t.Fatal("no api.port")
}
if !apiSec.HasKey("server_url") {
t.Fatal("no api.server_url")
}
_, err = apiSec.Key("port").Int()
if err != nil {
t.Fatal("invalid api.port")
}
}