mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
MINOR test cleanup
This commit is contained in:
parent
3cec831af7
commit
6e0c19bf1f
@ -1,6 +1,10 @@
|
||||
db.capped2.drop();
|
||||
db._dbCommand( { create: "capped2", capped: true, size: 1000, $nExtents: 11, autoIndexId: false } );
|
||||
t = db.capped2;
|
||||
tzz = db.capped2;
|
||||
|
||||
function debug( x ) {
|
||||
// print( x );
|
||||
}
|
||||
|
||||
var val = new Array( 2000 );
|
||||
var c = "";
|
||||
@ -9,43 +13,45 @@ for( i = 0; i < 2000; ++i, c += "-" ) {
|
||||
}
|
||||
|
||||
function checkIncreasing( i ) {
|
||||
res = t.find().sort( { $natural: -1 } );
|
||||
assert( res.hasNext() );
|
||||
res = tzz.find().sort( { $natural: -1 } );
|
||||
assert( res.hasNext(), "A" );
|
||||
var j = i;
|
||||
while( res.hasNext() ) {
|
||||
assert.eq( val[ j-- ].a, res.next().a );
|
||||
assert.eq( val[ j-- ].a, res.next().a, "B" );
|
||||
}
|
||||
res = t.find().sort( { $natural: 1 } );
|
||||
assert( res.hasNext() );
|
||||
res = tzz.find().sort( { $natural: 1 } );
|
||||
assert( res.hasNext(), "C" );
|
||||
while( res.hasNext() )
|
||||
assert.eq( val[ ++j ].a, res.next().a );
|
||||
assert.eq( j, i );
|
||||
assert.eq( val[ ++j ].a, res.next().a, "D" );
|
||||
assert.eq( j, i, "E" );
|
||||
}
|
||||
|
||||
function checkDecreasing( i ) {
|
||||
res = t.find().sort( { $natural: -1 } );
|
||||
assert( res.hasNext() );
|
||||
res = tzz.find().sort( { $natural: -1 } );
|
||||
assert( res.hasNext(), "F" );
|
||||
var j = i;
|
||||
while( res.hasNext() ) {
|
||||
assert.eq( val[ j++ ].a, res.next().a );
|
||||
assert.eq( val[ j++ ].a, res.next().a, "G" );
|
||||
}
|
||||
res = t.find().sort( { $natural: 1 } );
|
||||
assert( res.hasNext() );
|
||||
res = tzz.find().sort( { $natural: 1 } );
|
||||
assert( res.hasNext(), "H" );
|
||||
while( res.hasNext() )
|
||||
assert.eq( val[ --j ].a, res.next().a );
|
||||
assert.eq( j, i );
|
||||
assert.eq( val[ --j ].a, res.next().a, "I" );
|
||||
assert.eq( j, i, "J" );
|
||||
}
|
||||
|
||||
for( i = 0 ;; ++i ) {
|
||||
t.save( val[ i ] );
|
||||
if ( t.count() == 0 ) {
|
||||
assert( i > 100 );
|
||||
debug( "capped 2: " + i );
|
||||
tzz.save( val[ i ] );
|
||||
if ( tzz.count() == 0 ) {
|
||||
assert( i > 100, "K" );
|
||||
break;
|
||||
}
|
||||
checkIncreasing( i );
|
||||
}
|
||||
|
||||
for( i = 600 ; i >= 0 ; --i ) {
|
||||
t.save( val[ i ] );
|
||||
debug( "capped 2: " + i );
|
||||
tzz.save( val[ i ] );
|
||||
checkDecreasing( i );
|
||||
}
|
||||
|
@ -13,16 +13,16 @@ d = t.find().sort( { i: -1 } ).limit( 2 );
|
||||
d.next();
|
||||
d.next();
|
||||
|
||||
for( i = 20; i < 40; ++i ) {
|
||||
for( i = 20; t.findOne( { i:19 } ); ++i ) {
|
||||
t.save( { i : i } );
|
||||
}
|
||||
assert( !t.findOne( { i : 19 } ) );
|
||||
assert( !c.hasNext() );
|
||||
assert( !d.hasNext() );
|
||||
assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10 );
|
||||
//assert( !t.findOne( { i : 19 } ), "A" );
|
||||
assert( !c.hasNext(), "B" );
|
||||
assert( !d.hasNext(), "C" );
|
||||
assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10, "D" );
|
||||
|
||||
assert( t.findOne( { i : 38 } ) );
|
||||
t.remove( { i : 38 } );
|
||||
assert( db.getLastError().indexOf( "capped" ) >= 0 );
|
||||
assert( t.findOne( { i : i - 1 } ), "E" );
|
||||
t.remove( { i : i - 1 } );
|
||||
assert( db.getLastError().indexOf( "capped" ) >= 0, "F" );
|
||||
|
||||
assert( t.validate().valid );
|
||||
assert( t.validate().valid, "G" );
|
||||
|
Loading…
Reference in New Issue
Block a user