diff --git a/filter_test.go b/filter_test.go index 4de96f2..65d6c03 100644 --- a/filter_test.go +++ b/filter_test.go @@ -54,3 +54,16 @@ func TestFilter(t *testing.T) { 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"}}) +}