mirror of
https://github.com/mikefarah/yq.git
synced 2026-08-31 21:14:46 +08:00
Added support for load_props, added missing load_xml tests
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user