Skip to content

Commit

Permalink
added another upsert test
Browse files Browse the repository at this point in the history
  • Loading branch information
256dpi committed Jun 12, 2023
1 parent 62a644c commit 6df042c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,25 @@ func TestCollectionFindOneAndUpdateUpsert(t *testing.T) {
"baz": "quz",
},
}, dumpCollection(c, false))

// update after
out = nil
err = c.FindOneAndUpdate(nil, bson.M{
"_id": id2,
}, bson.M{
"$set": bson.M{
"bar": "baaz",
},
"$setOnInsert": bson.M{
"baz": "quuz",
},
}, options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After)).Decode(&out)
assert.NoError(t, err)
assert.Equal(t, bson.M{
"_id": id2,
"bar": "baaz",
"baz": "quz",
}, out)
})
}

Expand Down

0 comments on commit 6df042c

Please sign in to comment.