-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanualParser_test.go
47 lines (41 loc) · 1.31 KB
/
manualParser_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
package config
import (
"testing"
"github.com/vaughan0/go-ini"
)
// Test_ManualParser 测试manual解析
func Test_ManualParser(t *testing.T) {
p := NewManualParser()
p.SetConfig("app", "system", "version", "beta0.1")
if err := Init(false, p); err != nil {
t.Error(err)
}
if v, ok := Data("app").Get("system", "version"); !ok {
t.Error("没有找到设置的配置")
} else if v != "beta0.1" {
t.Error("找到的值与预设值不一致,设置的值:beta0.1,获取到的值:", v)
}
t.Log("test config success")
p = NewManualParser()
p.SetSection("app", "system", ini.Section{"appName": "config"})
if err := Init(false, p); err != nil {
t.Error(err)
}
if v, ok := Data("app").Get("system", "appName"); !ok {
t.Error("没有找到设置的配置")
} else if v != "config" {
t.Error("找到的值与预设值不一致,设置的值:config,获取到的值:", v)
}
t.Log("test section success")
p = NewManualParser()
p.SetFile("app", ini.File{"system": ini.Section{"author": "scofield"}})
if err := Init(false, p); err != nil {
t.Error(err)
}
if v, ok := Data("app").Get("system", "author"); !ok {
t.Error("没有找到设置的配置")
} else if v != "scofield" {
t.Error("找到的值与预设值不一致,设置的值:scofield,获取到的值:", v)
}
t.Log("test app success")
}