mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
select doc
This commit is contained in:
parent
2c062bc2a5
commit
3356061e1e
@ -6,29 +6,34 @@ import (
|
|||||||
|
|
||||||
var selectOperatorScenarios = []expressionScenario{
|
var selectOperatorScenarios = []expressionScenario{
|
||||||
{
|
{
|
||||||
document: `[cat,goat,dog]`,
|
description: "Select elements from array",
|
||||||
expression: `.[] | select(. == "*at")`,
|
document: `[cat,goat,dog]`,
|
||||||
|
expression: `.[] | select(. == "*at")`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[0], (!!str)::cat\n",
|
"D0, P[0], (!!str)::cat\n",
|
||||||
"D0, P[1], (!!str)::goat\n",
|
"D0, P[1], (!!str)::goat\n",
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
skipDoc: true,
|
||||||
document: `[hot, fot, dog]`,
|
document: `[hot, fot, dog]`,
|
||||||
expression: `.[] | select(. == "*at")`,
|
expression: `.[] | select(. == "*at")`,
|
||||||
expected: []string{},
|
expected: []string{},
|
||||||
}, {
|
}, {
|
||||||
|
skipDoc: true,
|
||||||
document: `a: [cat,goat,dog]`,
|
document: `a: [cat,goat,dog]`,
|
||||||
expression: `.a[] | select(. == "*at")`,
|
expression: `.a[] | select(. == "*at")`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[a 0], (!!str)::cat\n",
|
"D0, P[a 0], (!!str)::cat\n",
|
||||||
"D0, P[a 1], (!!str)::goat\n"},
|
"D0, P[a 1], (!!str)::goat\n"},
|
||||||
}, {
|
}, {
|
||||||
document: `a: { things: cat, bob: goat, horse: dog }`,
|
description: "Select matching values in map",
|
||||||
expression: `.a[] | select(. == "*at")`,
|
document: `a: { things: cat, bob: goat, horse: dog }`,
|
||||||
|
expression: `.a[] | select(. == "*at")`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[a things], (!!str)::cat\n",
|
"D0, P[a things], (!!str)::cat\n",
|
||||||
"D0, P[a bob], (!!str)::goat\n"},
|
"D0, P[a bob], (!!str)::goat\n"},
|
||||||
}, {
|
}, {
|
||||||
|
skipDoc: true,
|
||||||
document: `a: { things: {include: true}, notMe: {include: false}, andMe: {include: fold} }`,
|
document: `a: { things: {include: true}, notMe: {include: false}, andMe: {include: fold} }`,
|
||||||
expression: `.a[] | select(.include)`,
|
expression: `.a[] | select(.include)`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -36,6 +41,7 @@ var selectOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[a andMe], (!!map)::{include: fold}\n",
|
"D0, P[a andMe], (!!map)::{include: fold}\n",
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
|
skipDoc: true,
|
||||||
document: `[cat,~,dog]`,
|
document: `[cat,~,dog]`,
|
||||||
expression: `.[] | select(. == ~)`,
|
expression: `.[] | select(. == ~)`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
@ -48,4 +54,5 @@ func TestSelectOperatorScenarios(t *testing.T) {
|
|||||||
for _, tt := range selectOperatorScenarios {
|
for _, tt := range selectOperatorScenarios {
|
||||||
testScenario(t, &tt)
|
testScenario(t, &tt)
|
||||||
}
|
}
|
||||||
|
documentScenarios(t, "Select Operator", selectOperatorScenarios)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user