-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathne_test.go
65 lines (60 loc) · 1.24 KB
/
ne_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
package connor_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/SierraSoftworks/connor"
)
var _ = Describe("$ne", func() {
It("should be registered as an operator", func() {
Expect(Operators()).To(ContainElement("ne"))
})
cases := TestCases{
`{ "x": 1, "y": 2 }`: []TestCase{
{
"not match when the values are equal",
`{ "x": { "$ne": 1 } }`,
false,
false,
},
{
"match when the values are different",
`{ "x": { "$ne": 2 } }`,
true,
false,
},
{
"match when the field is not present",
`{ "a": { "$ne": 1 } }`,
true,
false,
},
{
"match when the types are different",
`{ "x": { "$ne": "1" } }`,
true,
false,
},
},
`{ "a": { "x": 1 }, "y": 2 }`: []TestCase{
{
"not match when a nested property has the same value",
`{ "a.x": { "$ne": 1 } }`,
false,
false,
},
{
"match when a nested property has a different value",
`{ "a": { "$ne": 1 } }`,
true,
false,
},
{
"match when a missing nested property is tested for value equality",
`{ "a": { "$ne": { "z": 1 } } }`,
true,
false,
},
},
}
cases.Generate(nil)
})