代码拉取完成,页面将自动刷新
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)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。