-
Notifications
You must be signed in to change notification settings - Fork 3
/
in_test.go
60 lines (54 loc) · 1.11 KB
/
in_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
package connor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/SierraSoftworks/connor"
)
var _ = Describe("$in", func() {
It("should be registered as an operator", func() {
Expect(Operators()).To(ContainElement("in"))
})
cases := TestCases{
`{ "x": 1, "y": 2 }`: []TestCase{
{
"match values which are in the query list",
`{ "x": { "$in": [1] } }`,
true,
false,
},
{
"not match values which are not in the query list",
`{ "x": { "$in": [2] } }`,
false,
false,
},
{
"match values which are in the query list with many options",
`{ "x": { "$in": [1, 2, 3] } }`,
true,
false,
},
},
`{ "a": { "x": 1 }, "y": 2 }`: []TestCase{
{
"match nested object properties",
`{ "a.x": { "$in": [1] } }`,
true,
false,
},
{
"not match nested properties if their full key path is not provided",
`{ "a": { "$in": [1] } }`,
false,
false,
},
{
"return an error if a query which is not a list is provided",
`{ "a": { "$in": 1 } }`,
false,
true,
},
},
}
cases.Generate(nil)
})