diff options
author | Aaron <aaron@10gen.com> | 2009-05-18 13:25:30 -0400 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2009-05-18 13:25:30 -0400 |
commit | e57cb387c4588b3ec9ff1cf04e60124237b32e95 (patch) | |
tree | e34ca3118e37bea47de99cca5b247d76156898d3 /jstests/capped3.js | |
parent | b773d2c965a3965fc470b0d1cac3f52346f80b3a (diff) | |
download | mongo-e57cb387c4588b3ec9ff1cf04e60124237b32e95.tar.gz |
add cloneCollectionAsCapped command
Diffstat (limited to 'jstests/capped3.js')
-rw-r--r-- | jstests/capped3.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/jstests/capped3.js b/jstests/capped3.js new file mode 100644 index 00000000000..7dc48559af2 --- /dev/null +++ b/jstests/capped3.js @@ -0,0 +1,27 @@ +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 );
\ No newline at end of file |