2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
// test 1
|
|
|
|
db.$cmd.findOne({reseterror:1});
|
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err == null );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err == null );
|
|
|
|
|
|
|
|
db.resetError();
|
|
|
|
assert( db.getLastError() == null );
|
|
|
|
assert( db.getPrevError().err == null , "preverror 1" );
|
|
|
|
|
|
|
|
// test 2
|
|
|
|
|
|
|
|
db.$cmd.findOne({forceerror:1});
|
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err != null );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err != null );
|
|
|
|
|
|
|
|
|
|
|
|
assert( db.getLastError() != null );
|
|
|
|
assert( db.getPrevError().err != null , "preverror 2" );
|
2009-03-26 18:57:46 +01:00
|
|
|
assert( db.getPrevError().nPrev == 1 );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2009-03-26 18:57:46 +01:00
|
|
|
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 );
|
|
|
|
|
2009-01-27 05:28:26 +01:00
|
|
|
db.resetError();
|
|
|
|
db.forceError();
|
|
|
|
db.foo.findOne();
|
|
|
|
assert( db.getLastError() == null , "getLastError 5" );
|
|
|
|
assert( db.getPrevError().err != null , "preverror 3" );
|
|
|
|
|
|
|
|
// test 3
|
|
|
|
db.$cmd.findOne({reseterror:1});
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err == null );
|