Test operators
This commit is contained in:
parent
2716580834
commit
feca0e9c61
@ -54,3 +54,16 @@ func TestFilter(t *testing.T) {
|
|||||||
assert.Equal(t, expected, Filter(doc1, doc2, doc3))
|
assert.Equal(t, expected, Filter(doc1, doc2, doc3))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOperators(t *testing.T) {
|
||||||
|
assert.Equal(t, Eq("field", 1), FilterDocument{"field": {"$eq": 1}})
|
||||||
|
assert.Equal(t, Ne("field", 1), FilterDocument{"field": {"$ne": 1}})
|
||||||
|
assert.Equal(t, Gt("field", 1), FilterDocument{"field": {"$gt": 1}})
|
||||||
|
assert.Equal(t, Gte("field", 1), FilterDocument{"field": {"$gte": 1}})
|
||||||
|
assert.Equal(t, Lt("field", 1), FilterDocument{"field": {"$lt": 1}})
|
||||||
|
assert.Equal(t, Lte("field", 1), FilterDocument{"field": {"$lte": 1}})
|
||||||
|
assert.Equal(t, In("field", []int{1, 2, 3}), FilterDocument{"field": {"$in": []int{1, 2, 3}}})
|
||||||
|
assert.Equal(t, Nin("field", []int{1, 2, 3}), FilterDocument{"field": {"$nin": []int{1, 2, 3}}})
|
||||||
|
assert.Equal(t, Exists("field", true), FilterDocument{"field": {"$exists": true}})
|
||||||
|
assert.Equal(t, Regex("field", "test"), FilterDocument{"field": {"$regex": "test"}})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user