Skip to content

Commit

Permalink
Added test to DBCollectionTest.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Oct 26, 2009
1 parent c821c6e commit aab47db
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/DBCollectionTest.js
Expand Up @@ -17,7 +17,7 @@ exports.testCreateCollection = function() {

obj = c.findOne(123);

print(typeof(obj));
//for (var i in obj.toMap()) print(i);
assert.isEqual(123, obj["_id"], "2");
assert.isEqual(2, obj["x"], "3");
assert.isEqual(2, obj["z"], "4");
Expand All @@ -36,5 +36,29 @@ exports.testCreateCollection = function() {
assert.isEqual(2, obj["y"], "11");
}

exports.testDropIndex = function() {
var c = _db.getCollection( "dropindex1" );
c.drop();

c.save( {"x": 1 });
assert.isEqual( 1 , c.getIndexInfo().size() );

c.ensureIndex( {"x": 1} );
assert.isEqual( 2 , c.getIndexInfo().size() );

c.dropIndexes();
assert.isEqual( 1 , c.getIndexInfo().size() );

c.ensureIndex( {"x": 1} );
assert.isEqual( 2 , c.getIndexInfo().size() );

c.ensureIndex( {"y": 1} );
assert.isEqual( 3 , c.getIndexInfo().size() );

c.dropIndex( {"x": 1} );
assert.isEqual( 2 , c.getIndexInfo().size() );

}

if (require.main === module.id)
require("os").exit(require("test/runner").run(exports));

0 comments on commit aab47db

Please sign in to comment.