summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-07-30 15:12:11 -0400
committerJason Rassi <rassi@10gen.com>2014-07-30 16:12:02 -0400
commit13fe3b061fa3c5970c40973d6f36f69fa06130a5 (patch)
tree22f051cf09c9c64149f68580aa001b0195983ef0 /jstests
parent76be742def16b4081e559374d66ede6a00cf3ff0 (diff)
downloadmongo-13fe3b061fa3c5970c40973d6f36f69fa06130a5.tar.gz
SERVER-14498 Add DeleteStage, rewrite DeleteExecutor to use it
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/stages_delete.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/core/stages_delete.js b/jstests/core/stages_delete.js
new file mode 100644
index 00000000000..f8c7fd14ea1
--- /dev/null
+++ b/jstests/core/stages_delete.js
@@ -0,0 +1,27 @@
+// Test basic delete stage functionality.
+var coll = db.stages_delete;
+var collScanStage = {cscan: {args: {direction: 1}, filter: {deleteMe: true}}};
+var deleteStage;
+
+// Test delete stage with isMulti: true.
+coll.drop();
+assert.writeOK(coll.insert({deleteMe: true}));
+assert.writeOK(coll.insert({deleteMe: true}));
+assert.writeOK(coll.insert({deleteMe: false}));
+deleteStage = {delete: {args: {node: collScanStage, isMulti: true, shouldCallLogOp: true}}};
+assert.eq(coll.count(), 3);
+assert.commandWorked(db.runCommand({stageDebug: {collection: coll.getName(), plan: deleteStage}}));
+assert.eq(coll.count(), 1);
+assert.eq(coll.count({deleteMe: false}), 1);
+
+// Test delete stage with isMulti: false.
+coll.drop();
+assert.writeOK(coll.insert({deleteMe: true}));
+assert.writeOK(coll.insert({deleteMe: true}));
+assert.writeOK(coll.insert({deleteMe: false}));
+deleteStage = {delete: {args: {node: collScanStage, isMulti: false, shouldCallLogOp: true}}};
+assert.eq(coll.count(), 3);
+assert.commandWorked(db.runCommand({stageDebug: {collection: coll.getName(), plan: deleteStage}}));
+assert.eq(coll.count(), 2);
+assert.eq(coll.count({deleteMe: true}), 1);
+assert.eq(coll.count({deleteMe: false}), 1);