3 Star 0 Fork 0

Gitee 极速下载/Configurator

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/progrium/configurator
克隆/下载
preprocessor_test.go 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import "testing"
const (
json_preprocess = `{
"tree": 3,
"other_thing": [ 1, 3, 2 ],
"preprocess_this": {
"$value": "/one",
"default": "nope"
},
"and_this": {
"$value": "/two"
},
"but_this_doesn't_exist": {
"$value": "non_existing_path"
},
"also_three": {
"$value": "/three"
}
}`
)
func TestPreprocessor(t *testing.T) {
p := &Preprocessor{}
store := NewTestStore()
config, err := NewConfig(store, "", "", "", "")
if err != nil {
t.Fatalf("failed to make config: %v", err)
}
config.cmdRunner = testCmd
loadBuiltinMacros(p, store, config)
preprocess := &JsonTree{}
input := []byte(json_preprocess)
err = preprocess.Load(input)
if err != nil {
t.Fatalf("failed to load input to preprocess, %v", err)
}
result := p.Process(preprocess)
if preprocess_this := result.Get("/preprocess_this"); preprocess_this != "1" {
t.Fatalf("preprocess_this did not preprocess right: %v", preprocess_this)
}
if and_this := result.Get("/and_this"); and_this != "2" {
t.Fatalf("and_this did not preprocess right: %v", and_this)
}
if btde := result.Get("/but_this_doesn't_exist"); btde != "" {
t.Fatalf("but_this_doesn't_exist did not preprocess right: %v", btde)
}
if also_three := result.Get("/also_three"); also_three != "3" {
t.Fatalf("also_three did not preprocess right: %v", also_three)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/Configurator.git
git@gitee.com:mirrors/Configurator.git
mirrors
Configurator
Configurator
master

搜索帮助