2010-01-12 20:56:14 +01:00
|
|
|
db.jstests_error1.drop();
|
2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
// test 1
|
|
|
|
db.$cmd.findOne({reseterror:1});
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err == null, "A" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err == null, "B" );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
db.resetError();
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.getLastError() == null, "C" );
|
2009-01-27 05:28:26 +01:00
|
|
|
assert( db.getPrevError().err == null , "preverror 1" );
|
|
|
|
|
|
|
|
// test 2
|
|
|
|
|
|
|
|
db.$cmd.findOne({forceerror:1});
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err != null, "D" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err != null, "E" );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.getLastError() != null, "F" );
|
2009-01-27 05:28:26 +01:00
|
|
|
assert( db.getPrevError().err != null , "preverror 2" );
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.getPrevError().nPrev == 1, "G" );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
2010-01-06 09:09:33 +01:00
|
|
|
db.jstests_error1.findOne();
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err == null, "H" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err != null, "I" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).nPrev == 2, "J" );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
2010-01-06 09:09:33 +01:00
|
|
|
db.jstests_error1.findOne();
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.$cmd.findOne({getlasterror:1}).err == null, "K" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err != null, "L" );
|
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).nPrev == 3, "M" );
|
2009-03-26 18:57:46 +01:00
|
|
|
|
2009-01-27 05:28:26 +01:00
|
|
|
db.resetError();
|
|
|
|
db.forceError();
|
2010-01-06 09:09:33 +01:00
|
|
|
db.jstests_error1.findOne();
|
2009-01-27 05:28:26 +01:00
|
|
|
assert( db.getLastError() == null , "getLastError 5" );
|
|
|
|
assert( db.getPrevError().err != null , "preverror 3" );
|
|
|
|
|
|
|
|
// test 3
|
|
|
|
db.$cmd.findOne({reseterror:1});
|
2010-01-12 20:56:06 +01:00
|
|
|
assert( db.$cmd.findOne({getpreverror:1}).err == null, "N" );
|