Permalink
Browse files

some more tests

  • Loading branch information...
1 parent f0e44b2 commit 34fb6220f20580c1f5e4d47cb9270a5cd3b9331d @erh erh committed Aug 11, 2009
Showing with 15 additions and 0 deletions.
  1. +12 −0 jstests/index_check3.js
  2. +3 −0 jstests/sharding/count1.js
View
@@ -48,4 +48,16 @@ assert.gt( 3 , t.find( { i : { $lte : 'a' } } ).explain().nscanned , "lte" );
//printjson( t.find( { i : { $gte : 'a' } } ).explain() );
// bug SERVER-99
assert.gt( 3 , t.find( { i : { $gte : 'a' } } ).explain().nscanned , "gte" );
+assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).count() , "gte a" );
+assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).itcount() , "gte b" );
+assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).sort( { i : 1 } ).count() , "gte c" );
+assert.eq( 1 , t.find( { i : { $gte : 'a' } } ).sort( { i : 1 } ).itcount() , "gte d" );
+t.save( { i : "b" } );
+
+assert.gt( 3 , t.find( { i : { $gte : 'a' } } ).explain().nscanned , "gte" );
+assert.eq( 2 , t.find( { i : { $gte : 'a' } } ).count() , "gte a2" );
+assert.eq( 2 , t.find( { i : { $gte : 'a' } } ).itcount() , "gte b2" );
+assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).itcount() , "gte c2" );
+assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).sort( { i : -1 } ).itcount() , "gte d2" );
+assert.eq( 2 , t.find( { i : { $gte : 'a' , $lt : MaxKey } } ).sort( { i : 1 } ).itcount() , "gte e2" );
@@ -33,11 +33,14 @@ s.adminCommand( { split : "test.foo" , find : { name : "joe" } } );
s.adminCommand( { split : "test.foo" , find : { name : "joe" } } );
assert.eq( 6 , db.foo.find().count() , "basic count after split " );
+assert.eq( 6 , db.foo.find().sort( { name : 1 } ).count() , "basic count after split sorted " );
s.adminCommand( { moveshard : "test.foo" , find : { name : "joe" } , to : seconday.getMongo().name } );
assert.eq( 3 , primary.foo.find().toArray().length , "primary count" );
assert.eq( 3 , seconday.foo.find().toArray().length , "secondary count" );
+assert.eq( 3 , primary.foo.find().sort( { name : 1 } ).toArray().length , "primary count sorted" );
+assert.eq( 3 , seconday.foo.find().sort( { name : 1 } ).toArray().length , "secondary count sorted" );
assert.eq( 6 , db.foo.find().toArray().length , "total count after move" );
assert.eq( 6 , db.foo.find().sort( { name : 1 } ).toArray().length , "total count() sorted" );

0 comments on commit 34fb622

Please sign in to comment.