Skip to content

Commit

Permalink
x/mango: Add tests for subfield matching
Browse files Browse the repository at this point in the history
  • Loading branch information
skaggmannen committed Sep 10, 2024
1 parent 822c100 commit a797e87
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions x/mango/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,53 @@ func TestMatch(t *testing.T) {
doc: "bar",
want: false,
})
tests.Add("field selector, nested", test{
sel: &fieldNode{
field: "foo.bar.baz",
cond: &conditionNode{
op: OpEqual,
cond: "hello",
},
},
doc: map[string]interface{}{
"foo": map[string]interface{}{
"bar": map[string]interface{}{
"baz": "hello",
},
},
},
want: true,
})
tests.Add("field selector, nested, non-object", test{
sel: &fieldNode{
field: "foo.bar.baz",
cond: &conditionNode{
op: OpEqual,
cond: "hello",
},
},
doc: map[string]interface{}{
"foo": "hello",
},
want: false,
})
tests.Add("!field selector, nested", test{
sel: &fieldNode{
field: "foo.bar.baz",
cond: &conditionNode{
op: OpEqual,
cond: "hello",
},
},
doc: map[string]interface{}{
"foo": map[string]interface{}{
"bar": map[string]interface{}{
"buzz": "hello",
},
},
},
want: false,
})
tests.Add("elemMatch", test{
sel: &fieldNode{
field: "foo",
Expand Down

0 comments on commit a797e87

Please sign in to comment.