-
-
Notifications
You must be signed in to change notification settings - Fork 610
/
operator_column_test.go
47 lines (44 loc) · 1.01 KB
/
operator_column_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package yqlib
import (
"testing"
)
var columnOperatorScenarios = []expressionScenario{
{
description: "Returns column of _value_ node",
document: "a: cat\nb: bob",
expression: `.b | column`,
expected: []string{
"D0, P[b], (!!int)::4\n",
},
},
{
description: "Returns column of _key_ node",
subdescription: "Pipe through the key operator to get the column of the key",
document: "a: cat\nb: bob",
expression: `.b | key | column`,
expected: []string{
"D0, P[b], (!!int)::1\n",
},
},
{
description: "First column is 1",
document: "a: cat",
expression: `.a | key | column`,
expected: []string{
"D0, P[a], (!!int)::1\n",
},
},
{
description: "No column data is 0",
expression: `{"a": "new entry"} | column`,
expected: []string{
"D0, P[], (!!int)::0\n",
},
},
}
func TestColumnOperatorScenarios(t *testing.T) {
for _, tt := range columnOperatorScenarios {
testScenario(t, &tt)
}
documentOperatorScenarios(t, "column", columnOperatorScenarios)
}