summaryrefslogtreecommitdiff
path: root/src/mongo/shell
diff options
context:
space:
mode:
authorLaszlo Boszormenyi (GCS) <gcs@debian.org>2014-04-27 21:49:01 +0200
committerLaszlo Boszormenyi (GCS) <gcs@debian.org>2014-04-27 21:49:01 +0200
commit547377230880c8e9def9ee9458ae69d298918467 (patch)
tree2cb8394f8eb02c2499581cc1afd25d2929571983 /src/mongo/shell
parent65585c90b12d6523bea75a2aebaae2a2fdf9e641 (diff)
Imported Upstream version 2.4.9upstream/2.4.9
Diffstat (limited to 'src/mongo/shell')
-rw-r--r--src/mongo/shell/assert.js38
-rw-r--r--src/mongo/shell/dbshell.cpp4
2 files changed, 41 insertions, 1 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index b1279028307..0e84c52d11c 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -225,3 +225,41 @@ assert.close = function(a, b, msg, places){
doassert(a + " is not equal to " + b + " within " + places +
" places, diff: " + (a-b) + " : " + msg);
};
+
+assert.gleSuccess = function(db, msg) {
+ var gle = db.getLastErrorObj();
+ if (gle.err) {
+ if (typeof(msg) == "function")
+ msg = msg(gle);
+ doassert("getLastError not null:" + tojson(gle) + " :" + msg);
+ }
+}
+
+assert.gleError = function(db, msg) {
+ var gle = db.getLastErrorObj();
+ if (!gle.err) {
+ if (typeof(msg) == "function")
+ msg = msg(gle);
+ doassert("getLastError is null: " + tojson(gle) + " :" + msg);
+ }
+}
+
+assert.gleErrorCode = function(db, code, msg) {
+ var gle = db.getLastErrorObj();
+ if (gle.err && (gle.code == code)) {
+ if (typeof(msg) == "function")
+ msg = msg(gle);
+ doassert("getLastError not null or missing code( " + code + "): "
+ + tojson(gle) + " :" + msg);
+ }
+}
+
+assert.gleErrorRegex = function(db, regex, msg) {
+ var gle = db.getLastErrorObj();
+ if (!gle.err || !regex.test(gle.err)) {
+ if (typeof(msg) == "function")
+ msg = msg(gle);
+ doassert("getLastError is null or doesn't match regex (" + regex + "): "
+ + tojson(gle) + " :" + msg);
+ }
+}
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 5934e862076..6a790ee2adb 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -75,7 +75,9 @@ void generateCompletions( const string& prefix , vector<string>& all ) {
try {
BSONObj args = BSON( "0" << prefix );
- shellMainScope->invokeSafe( "function callShellAutocomplete(x) {shellAutocomplete(x)}", &args, 0, 1000 );
+ shellMainScope->invokeSafe("function callShellAutocomplete(x) {shellAutocomplete(x)}",
+ &args,
+ NULL);
BSONObjBuilder b;
shellMainScope->append( b , "" , "__autocomplete__" );
BSONObj res = b.obj();