-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
func_equal_test.go
83 lines (77 loc) · 1.32 KB
/
func_equal_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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package dasel
import (
"testing"
)
func TestEqualFunc(t *testing.T) {
t.Run("Args", selectTestErr(
"equal()",
map[string]interface{}{},
&ErrUnexpectedFunctionArgs{
Function: "equal",
Args: []string{},
}),
)
t.Run(
"Single Equal",
selectTest(
"name.all().equal(key(),first)",
map[string]interface{}{
"name": map[string]interface{}{
"first": "Tom",
"last": "Wright",
},
},
[]interface{}{
true,
false,
},
),
)
t.Run(
"Multi Equal",
selectTest(
"name.all().equal(key(),first,key(),first)",
map[string]interface{}{
"name": map[string]interface{}{
"first": "Tom",
"last": "Wright",
},
},
[]interface{}{
true,
false,
},
),
)
t.Run(
"Single Equal Optional Field",
selectTest(
"all().equal(primary,true)",
[]interface{}{
map[string]interface{}{
"name": "red",
"hex": "ff0000",
"primary": true,
},
map[string]interface{}{
"name": "green",
"hex": "00ff00",
"primary": true,
},
map[string]interface{}{
"name": "blue",
"hex": "0000ff",
"primary": true,
},
map[string]interface{}{
"name": "orange",
"hex": "ffa500",
"primary": false,
},
},
[]interface{}{
true, true, true, false,
},
),
)
}