mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
46 lines
824 B
Go
46 lines
824 B
Go
package treeops
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var collectOperatorScenarios = []expressionScenario{
|
|
{
|
|
document: `{}`,
|
|
expression: `["cat"]`,
|
|
expected: []string{
|
|
"D0, P[], (!!seq)::- cat\n",
|
|
},
|
|
}, {
|
|
document: `{}`,
|
|
expression: `["cat", "dog"]`,
|
|
expected: []string{
|
|
"D0, P[], (!!seq)::- cat\n- dog\n",
|
|
},
|
|
}, {
|
|
document: `{}`,
|
|
expression: `1 | collect`,
|
|
expected: []string{
|
|
"D0, P[], (!!seq)::- 1\n",
|
|
},
|
|
}, {
|
|
document: `[1,2,3]`,
|
|
expression: `[.[]]`,
|
|
expected: []string{
|
|
"D0, P[], (!!seq)::- 1\n- 2\n- 3\n",
|
|
},
|
|
}, {
|
|
document: `a: {b: [1,2,3]}`,
|
|
expression: `[.a.b[]]`,
|
|
expected: []string{
|
|
"D0, P[a b], (!!seq)::- 1\n- 2\n- 3\n",
|
|
},
|
|
},
|
|
}
|
|
|
|
func TestCollectOperatorScenarios(t *testing.T) {
|
|
for _, tt := range collectOperatorScenarios {
|
|
testScenario(t, &tt)
|
|
}
|
|
}
|