summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorRandolph Tan <ren@Randolphs-MacBook-Air.local>2012-02-29 17:27:49 -0500
committerRandolph Tan <ren@Randolphs-MacBook-Air.local>2012-03-01 10:51:58 -0500
commitcaf6045dd9ec2d4e093a2c2790910eb9ca7900a6 (patch)
tree15b365d277f3dc7a4b209e362ffe8ac7a2f45026 /jstests
parent06d2438c122d1a20750f2bf3197df735367e22c4 (diff)
downloadmongo-caf6045dd9ec2d4e093a2c2790910eb9ca7900a6.tar.gz
SERVER-5020 Mongo shell should check the validity of the db name for use dbname
No automated test for actually using "use" since the shell cannot parse it correctly when "use" is placed inside a function and assert.throws requires you to pass a function to it. Tested ok on SpiderMonkey and V8 by hand.
Diffstat (limited to 'jstests')
-rw-r--r--jstests/db.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/jstests/db.js b/jstests/db.js
new file mode 100644
index 00000000000..5ed978874c3
--- /dev/null
+++ b/jstests/db.js
@@ -0,0 +1,11 @@
+function testInvalidDBNameThrowsExceptionWithConstructor() {
+ assert.throws( function() { return new DB( null, "*?" ); } );
+}
+
+function testInvalidDBNameThrowsExceptionWithSibling() {
+ assert.throws( function() { return db.getSiblingDB( "/\\" ); } );
+}
+
+testInvalidDBNameThrowsExceptionWithConstructor();
+testInvalidDBNameThrowsExceptionWithSibling();
+