forked from mikefarah/yq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operator_filter_test.go
49 lines (46 loc) · 921 Bytes
/
operator_filter_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
48
49
package yqlib
import (
"testing"
)
var filterOperatorScenarios = []expressionScenario{
{
description: "Filter array",
document: `[1,2,3]`,
expression: `filter(. < 3)`,
expected: []string{
"D0, P[], (!!seq)::- 1\n",
"D0, P[], (!!seq)::- 2\n",
},
},
{
skipDoc: true,
document: `[1,2,3]`,
expression: `filter(. > 1)`,
expected: []string{
"D0, P[], (!!seq)::- 2\n",
"D0, P[], (!!seq)::- 3\n",
},
},
{
skipDoc: true,
description: "Filter array to empty",
document: `[1,2,3]`,
expression: `filter(. > 4)`,
expected: []string{
},
},
{
skipDoc: true,
description: "Filter empty array",
document: `[]`,
expression: `filter(. > 1)`,
expected: []string{
},
},
}
func TestFilterOperatorScenarios(t *testing.T) {
for _, tt := range filterOperatorScenarios {
testScenario(t, &tt)
}
documentOperatorScenarios(t, "filter", filterOperatorScenarios)
}