diff options
author | Geert Bosch <geert@mongodb.com> | 2020-09-04 13:05:41 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-20 00:20:18 +0000 |
commit | 1e9b12b0f58fef211740546d5d162694d5cbbcf7 (patch) | |
tree | 110cf4f681ea057a55deb2463862827404ae5279 | |
parent | 333e4e86d03e3bbf1d89654d40dfffc9525eb112 (diff) | |
download | mongo-1e9b12b0f58fef211740546d5d162694d5cbbcf7.tar.gz |
SERVER-47647 Test that duplicate key error message has correct namespace after rename
-rw-r--r-- | jstests/noPassthroughWithMongod/dup_key_after_rename.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/dup_key_after_rename.js b/jstests/noPassthroughWithMongod/dup_key_after_rename.js new file mode 100644 index 00000000000..b3853264ba1 --- /dev/null +++ b/jstests/noPassthroughWithMongod/dup_key_after_rename.js @@ -0,0 +1,17 @@ +// SERVER-47647 Test that duplicate key error message has correct namespace after rename +(function() { +"use strict"; +const before = db.dup_key_before_rename; +before.drop(); + +const after = db.dup_key_after_rename; +after.drop(); + +assert.commandWorked(before.insert({_id: 1})); +assert.commandWorked(before.renameCollection(after.getName())); +const res = after.insert({_id: 1}); +assert.commandFailedWithCode(res, ErrorCodes.DuplicateKey); +const err = res.getWriteError(); +assert.gt( + err.errmsg.indexOf(after.getName()), 0, "error message does not contain new collection name"); +})(); |