summaryrefslogtreecommitdiff
path: root/jstests/rename.js
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-04-07 16:42:06 -0400
committerAaron <aaron@10gen.com>2009-04-07 16:42:06 -0400
commit5f9d2b6aa5ed0ac05bf42e93bcb608ad7aa2c01d (patch)
tree916b8fe854f630eb4e87b6ec07ac3715c6aed883 /jstests/rename.js
parent25cbcbcba6178588e050deacd06f1568166e45ec (diff)
downloadmongo-5f9d2b6aa5ed0ac05bf42e93bcb608ad7aa2c01d.tar.gz
add renameCollection command
Diffstat (limited to 'jstests/rename.js')
-rw-r--r--jstests/rename.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/jstests/rename.js b/jstests/rename.js
new file mode 100644
index 00000000000..0ec83b77e57
--- /dev/null
+++ b/jstests/rename.js
@@ -0,0 +1,24 @@
+admin = db.getMongo().getDB( "admin" );
+
+a = db.jstests_rename_a;
+b = db.jstests_rename_b;
+c = db.jstests_rename_c;
+
+a.drop();
+b.drop();
+c.drop();
+
+a.save( {a: 1} );
+a.save( {a: 2} );
+a.ensureIndex( {a:1} );
+a.ensureIndex( {b:1} );
+
+c.save( {a: 100} );
+assert.commandFailed( admin.runCommand( {renameCollection:"test.jstests_rename_a", to:"test.jstests_rename_c"} ) );
+
+assert.commandWorked( admin.runCommand( {renameCollection:"test.jstests_rename_a", to:"test.jstests_rename_b"} ) );
+assert.eq( 0, a.find().count() );
+
+assert.eq( 2, b.find().count() );
+assert.eq( 2, db.system.indexes.find( {ns:"test.jstests_rename_b"} ).count() );
+assert( b.find( {a:1} ).explain().cursor.match( /^BtreeCursor/ ) );