yq/pkg/yqlib/operator_union_test.go

34 lines
679 B
Go
Raw Normal View History

2020-11-03 23:48:43 +00:00
package yqlib
2020-10-17 11:10:47 +00:00
import (
"testing"
)
var unionOperatorScenarios = []expressionScenario{
{
2020-11-17 23:32:30 +00:00
description: "Combine scalars",
expression: `1, true, "cat"`,
2020-10-17 11:10:47 +00:00
expected: []string{
"D0, P[], (!!int)::1\n",
"D0, P[], (!!bool)::true\n",
"D0, P[], (!!str)::cat\n",
2020-11-17 23:32:30 +00:00
},
},
{
description: "Combine selected paths",
document: `{a: fieldA, b: fieldB, c: fieldC}`,
expression: `.a, .c`,
expected: []string{
"D0, P[a], (!!str)::fieldA\n",
"D0, P[c], (!!str)::fieldC\n",
2020-10-17 11:10:47 +00:00
},
},
}
func TestUnionOperatorScenarios(t *testing.T) {
for _, tt := range unionOperatorScenarios {
testScenario(t, &tt)
}
2020-11-22 02:16:54 +00:00
documentScenarios(t, "Union", unionOperatorScenarios)
2020-10-17 11:10:47 +00:00
}