0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-28 16:24:56 +01:00
mongodb/jstests/capped3.js
2009-05-18 13:25:30 -04:00

27 lines
707 B
JavaScript

t = db.jstests_capped3;
t2 = db.jstests_capped3_clone;
t.drop();
t2.drop();
for( i = 0; i < 1000; ++i ) {
t.save( {i:i} );
}
assert.commandWorked( db.runCommand( { cloneCollectionAsCapped:"jstests_capped3", toCollection:"jstests_capped3_clone", size:100000 } ) );
c = t2.find();
for( i = 0; i < 1000; ++i ) {
assert.eq( i, c.next().i );
}
assert( !c.hasNext() );
t.drop();
t2.drop();
for( i = 0; i < 1000; ++i ) {
t.save( {i:i} );
}
assert.commandWorked( db.runCommand( { cloneCollectionAsCapped:"jstests_capped3", toCollection:"jstests_capped3_clone", size:1000 } ) );
c = t2.find().sort( {$natural:-1} );
i = 999;
while( c.hasNext() ) {
assert.eq( i--, c.next().i );
}
assert( i < 990 );