Skip to content

Commit

Permalink
Add upsert tests (#3864)
Browse files Browse the repository at this point in the history
Closes #3856.
  • Loading branch information
wazir-ahmed authored Dec 18, 2023
1 parent 39aee11 commit 82143ff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions integration/findandmodify_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,26 @@ func TestFindAndModifyCompatUpsertSet(t *testing.T) {
{"update", bson.D{{"$set", bson.D{{"_id", "int32"}, {"v", int32(2)}}}}},
},
},
"UpsertQueryOperatorEq": {
command: bson.D{
{"query", bson.D{{"_id", bson.D{{"$eq", "non-existent"}}}}},
{"upsert", true},
{"update", bson.D{{"$set", bson.D{{"new", "val"}}}}},
},
skip: "https://github.com/FerretDB/FerretDB/issues/3856",
},
"UpsertQueryOperatorMixed": {
command: bson.D{
{"query", bson.D{
{"_id", bson.D{{"$eq", "non-existent"}}},
{"v", bson.D{{"$lt", 43}}},
{"non_existent", int32(0)},
}},
{"upsert", true},
{"update", bson.D{{"$set", bson.D{{"new", "val"}}}}},
},
skip: "https://github.com/FerretDB/FerretDB/issues/3856",
},
}

testFindAndModifyCompat(t, testCases)
Expand Down
16 changes: 16 additions & 0 deletions integration/update_field_compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,22 @@ func TestUpdateFieldCompatMixed(t *testing.T) {
update: bson.D{{"$foo", bson.D{{"foo", int32(1)}}}},
resultType: emptyResult,
},
"UpsertQueryOperatorEq": {
filter: bson.D{{"_id", bson.D{{"$eq", "non-existent"}}}},
update: bson.D{{"$set", bson.D{{"new", "val"}}}},
updateOpts: options.Update().SetUpsert(true),
skip: "https://github.com/FerretDB/FerretDB/issues/3856",
},
"UpsertQueryOperatorMixed": {
filter: bson.D{
{"_id", bson.D{{"$eq", "non-existent"}}},
{"v", bson.D{{"$lt", 43}}},
{"non_existent", int32(0)},
},
update: bson.D{{"$set", bson.D{{"new", "val"}}}},
updateOpts: options.Update().SetUpsert(true),
skip: "https://github.com/FerretDB/FerretDB/issues/3856",
},
}

testUpdateCompat(t, testCases)
Expand Down

0 comments on commit 82143ff

Please sign in to comment.