Permalink
Browse files

More prev error tests

  • Loading branch information...
1 parent 625b063 commit c77a66ec8b29a109ffa14b6b575985b1728df945 @astaple astaple committed Mar 26, 2009
Showing with 20 additions and 1 deletion.
  1. +6 −1 jstests/error1.js
  2. +7 −0 jstests/remove5.js
  3. +7 −0 jstests/update4.js
View
7 jstests/error1.js
@@ -17,13 +17,18 @@ assert( db.$cmd.findOne({getpreverror:1}).err != null );
assert( db.getLastError() != null );
assert( db.getPrevError().err != null , "preverror 2" );
-
+assert( db.getPrevError().nPrev == 1 );
db.foo.findOne();
assert( db.$cmd.findOne({getlasterror:1}).err == null );
assert( db.$cmd.findOne({getpreverror:1}).err != null );
assert( db.$cmd.findOne({getpreverror:1}).nPrev == 2 );
+db.foo.findOne();
+assert( db.$cmd.findOne({getlasterror:1}).err == null );
+assert( db.$cmd.findOne({getpreverror:1}).err != null );
+assert( db.$cmd.findOne({getpreverror:1}).nPrev == 3 );
+
db.resetError();
db.forceError();
db.foo.findOne();
View
7 jstests/remove5.js
@@ -15,3 +15,10 @@ for( i = 0; i < 10; ++i ) {
}
f.remove( {} );
assert.eq( 10, getLastError().n );
+assert.eq( 10, db.getPrevError().n );
+assert.eq( 1, db.getPrevError().nPrev );
+
+f.findOne();
+assert.eq( 0, getLastError().n );
+assert.eq( 10, db.getPrevError().n );
+assert.eq( 2, db.getPrevError().nPrev );
View
7 jstests/update4.js
@@ -17,6 +17,13 @@ f.update( {a:1}, {a:1}, true );
assert.eq( false, getLastError().updatedExisting );
f.update( {a:1}, {a:1}, true );
assert.eq( true, getLastError().updatedExisting );
+assert.eq( true, db.getPrevError().updatedExisting );
+assert.eq( 1, db.getPrevError().nPrev );
+
+f.findOne();
+assert.eq( undefined, getLastError().updatedExisting );
+assert.eq( true, db.getPrevError().updatedExisting );
+assert.eq( 2, db.getPrevError().nPrev );
db.forceError();
assert.eq( undefined, getLastError().updatedExisting );

0 comments on commit c77a66e

Please sign in to comment.