-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathor_test.go
61 lines (54 loc) · 1.2 KB
/
or_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
package connor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/SierraSoftworks/connor"
)
var _ = Describe("$or", func() {
It("should be registered as an operator", func() {
Expect(Operators()).To(ContainElement("or"))
})
cases := TestCases{
`{ "x": 1, "y": 2 }`: []TestCase{
{
"match equality of values implicitly",
`{ "x": { "$or": [1] } }`,
true,
false,
},
{
"not match inequality of values implicitly",
`{ "x": { "$or": [2] } }`,
false,
false,
},
{
"match using explicit value comparison operators",
`{ "x": { "$or": [{ "$eq": 1 }] } }`,
true,
false,
},
{
"return an error if you do not provide a list of options",
`{ "x": { "$or": 2 } }`,
false,
true,
},
},
`{ "a": { "x": 1 }, "y": 2 }`: []TestCase{
{
"not match if values are not deep-equal with an explicit operator",
`{ "x": { "$or": [{ "$eq": 1 }] } }`,
false,
false,
},
{
"match if a complex value comparison is performed",
`{ "a": { "$or": [{ "x": { "$in": [1] } }] } }`,
true,
false,
},
},
}
cases.Generate(nil)
})