Added support for load_props, added missing load_xml tests

This commit is contained in:
Mike Farah
2022-02-15 14:51:22 +11:00
parent e1b5e90adf
commit 75fffc17e1
6 changed files with 125 additions and 6 deletions
+26 -1
View File
@@ -35,11 +35,36 @@ var loadScenarios = []expressionScenario{
description: "Replace node with referenced file as string",
subdescription: "This will work for any text based file",
document: `{something: {file: "thing.yml"}}`,
expression: `.something |= strload("../../examples/" + .file)`,
expression: `.something |= load_str("../../examples/" + .file)`,
expected: []string{
"D0, P[], (doc)::{something: \"a: apple is included\\nb: cool.\"}\n",
},
},
{
description: "Load from XML",
document: "cool: things",
expression: `.more_stuff = load_xml("../../examples/small.xml")`,
expected: []string{
"D0, P[], (doc)::cool: things\nmore_stuff:\n this: is some xml\n",
},
},
{
description: "Load from Properties",
document: "cool: things",
expression: `.more_stuff = load_props("../../examples/small.properties")`,
expected: []string{
"D0, P[], (doc)::cool: things\nmore_stuff:\n this:\n is: a properties file\n",
},
},
{
description: "Merge from properties",
subdescription: "This can be used as a convenient way to update a yaml document",
document: "this:\n is: from yaml\n cool: ay\n",
expression: `. *= load_props("../../examples/small.properties")`,
expected: []string{
"D0, P[], (!!map)::this:\n is: a properties file\n cool: ay\n",
},
},
}
func TestLoadScenarios(t *testing.T) {