-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathand_test.go
31 lines (26 loc) · 1.12 KB
/
and_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
package connor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/SierraSoftworks/connor"
)
var _ = Describe("$and", func() {
It("should be registered as an operator", func() {
Expect(Operators()).To(ContainElement("and"))
})
cases := TestCases{
`{ "x": 1, "y": 2 }`: []TestCase{
{"match with a single value", `{ "x": { "$and": [1] } }`, true, false},
{"not match with a single value", `{ "x": { "$and": [2] } }`, false, false},
{"match with a single operation", `{ "x": { "$and": [{ "$eq": 1 }] } }`, true, false},
{"not match with a single operation", `{ "x": { "$and": [{ "$eq": 2 }] } }`, false, false},
{"not match with multiple values", `{ "x": { "$and": [1, 2] } }`, false, false},
{"error without an array of values", `{ "x": { "$and": 1 } }`, false, true},
},
`{ "a": { "x": 1 }, "y": 2 }`: []TestCase{
{"not match when a nested operator doesn't match", `{ "x": { "$and": [{ "$eq": 1 }] } }`, false, false},
{"match when nested operators all match", `{ "a.x": { "$and": [{ "$in": [1, 3] }, { "$in": [1, 2] }] } }`, true, false},
},
}
cases.Generate(nil)
})