mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
13d1bbb45f
Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
40 lines
815 B
Go
40 lines
815 B
Go
package yqlib
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
var pipeOperatorScenarios = []expressionScenario{
|
|
{
|
|
description: "Simple Pipe",
|
|
document: `{a: {b: cat}}`,
|
|
expression: `.a | .b`,
|
|
expected: []string{
|
|
"D0, P[a b], (!!str)::cat\n",
|
|
},
|
|
},
|
|
{
|
|
description: "Multiple updates",
|
|
document: `{a: cow, b: sheep, c: same}`,
|
|
expression: `.a = "cat" | .b = "dog"`,
|
|
expected: []string{
|
|
"D0, P[], (!!map)::{a: cat, b: dog, c: same}\n",
|
|
},
|
|
},
|
|
{
|
|
skipDoc: true,
|
|
description: "Don't pass readonly context",
|
|
expression: `(3 + 4) | ({} | .b = "dog")`,
|
|
expected: []string{
|
|
"D0, P[], (!!map)::b: dog\n",
|
|
},
|
|
},
|
|
}
|
|
|
|
func TestPipeOperatorScenarios(t *testing.T) {
|
|
for _, tt := range pipeOperatorScenarios {
|
|
testScenario(t, &tt)
|
|
}
|
|
documentOperatorScenarios(t, "pipe", pipeOperatorScenarios)
|
|
}
|