This commit is contained in:
Mike Farah
2020-11-18 10:32:30 +11:00
parent 3356061e1e
commit dcacad1e7e
14 changed files with 706 additions and 55 deletions
+12 -10
View File
@@ -6,20 +6,21 @@ import (
var unionOperatorScenarios = []expressionScenario{
{
document: `{}`,
expression: `"cat", "dog"`,
expected: []string{
"D0, P[], (!!str)::cat\n",
"D0, P[], (!!str)::dog\n",
},
}, {
document: `{a: frog}`,
expression: `1, true, "cat", .a`,
description: "Combine scalars",
expression: `1, true, "cat"`,
expected: []string{
"D0, P[], (!!int)::1\n",
"D0, P[], (!!bool)::true\n",
"D0, P[], (!!str)::cat\n",
"D0, P[a], (!!str)::frog\n",
},
},
{
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",
},
},
}
@@ -28,4 +29,5 @@ func TestUnionOperatorScenarios(t *testing.T) {
for _, tt := range unionOperatorScenarios {
testScenario(t, &tt)
}
documentScenarios(t, "Union Operator", unionOperatorScenarios)
}