mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
more docs
This commit is contained in:
parent
af2aa9ad91
commit
b3efcdc202
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
var recursiveDescentOperatorScenarios = []expressionScenario{
|
var recursiveDescentOperatorScenarios = []expressionScenario{
|
||||||
{
|
{
|
||||||
|
skipDoc: true,
|
||||||
document: `cat`,
|
document: `cat`,
|
||||||
expression: `..`,
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -13,6 +14,7 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
skipDoc: true,
|
||||||
document: `{a: frog}`,
|
document: `{a: frog}`,
|
||||||
expression: `..`,
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -21,8 +23,9 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
document: `{a: {b: apple}}`,
|
description: "Map",
|
||||||
expression: `..`,
|
document: `{a: {b: apple}}`,
|
||||||
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!map)::{a: {b: apple}}\n",
|
"D0, P[], (!!map)::{a: {b: apple}}\n",
|
||||||
"D0, P[a], (!!map)::{b: apple}\n",
|
"D0, P[a], (!!map)::{b: apple}\n",
|
||||||
@ -30,8 +33,9 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
document: `[1,2,3]`,
|
description: "Array",
|
||||||
expression: `..`,
|
document: `[1,2,3]`,
|
||||||
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!seq)::[1, 2, 3]\n",
|
"D0, P[], (!!seq)::[1, 2, 3]\n",
|
||||||
"D0, P[0], (!!int)::1\n",
|
"D0, P[0], (!!int)::1\n",
|
||||||
@ -40,8 +44,9 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
document: `[{a: cat},2,true]`,
|
description: "Array of maps",
|
||||||
expression: `..`,
|
document: `[{a: cat},2,true]`,
|
||||||
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!seq)::[{a: cat}, 2, true]\n",
|
"D0, P[], (!!seq)::[{a: cat}, 2, true]\n",
|
||||||
"D0, P[0], (!!map)::{a: cat}\n",
|
"D0, P[0], (!!map)::{a: cat}\n",
|
||||||
@ -51,8 +56,9 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
document: `{a: &cat {c: frog}, b: *cat}`,
|
description: "Aliases are not traversed",
|
||||||
expression: `..`,
|
document: `{a: &cat {c: frog}, b: *cat}`,
|
||||||
|
expression: `..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!map)::{a: &cat {c: frog}, b: *cat}\n",
|
"D0, P[], (!!map)::{a: &cat {c: frog}, b: *cat}\n",
|
||||||
"D0, P[a], (!!map)::&cat {c: frog}\n",
|
"D0, P[a], (!!map)::&cat {c: frog}\n",
|
||||||
@ -61,8 +67,9 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
document: mergeDocSample,
|
description: "Merge docs are not traversed",
|
||||||
expression: `.foobar | ..`,
|
document: mergeDocSample,
|
||||||
|
expression: `.foobar | ..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[foobar], (!!map)::c: foobar_c\n!!merge <<: *foo\nthing: foobar_thing\n",
|
"D0, P[foobar], (!!map)::c: foobar_c\n!!merge <<: *foo\nthing: foobar_thing\n",
|
||||||
"D0, P[foobar c], (!!str)::foobar_c\n",
|
"D0, P[foobar c], (!!str)::foobar_c\n",
|
||||||
@ -71,6 +78,7 @@ var recursiveDescentOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
skipDoc: true,
|
||||||
document: mergeDocSample,
|
document: mergeDocSample,
|
||||||
expression: `.foobarList | ..`,
|
expression: `.foobarList | ..`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -88,4 +96,5 @@ func TestRecursiveDescentOperatorScenarios(t *testing.T) {
|
|||||||
for _, tt := range recursiveDescentOperatorScenarios {
|
for _, tt := range recursiveDescentOperatorScenarios {
|
||||||
testScenario(t, &tt)
|
testScenario(t, &tt)
|
||||||
}
|
}
|
||||||
|
documentScenarios(t, "Recursive Descent Operator", recursiveDescentOperatorScenarios)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user