Permalink
Browse files

Fixed unit tests to work with last version of Narwhal

  • Loading branch information...
sergi committed Feb 12, 2010
1 parent 4bea639 commit 329945e9913cbbdb1efd853d27d7f8c12c21252a
Showing with 26 additions and 30 deletions.
  1. +1 −1 tests/DBCollectionTest.js
  2. +1 −1 tests/DBCursorTest.js
  3. +24 −28 tests/DBTest.js
@@ -55,5 +55,5 @@ exports.testDropIndex = function() {
}
-if (require.main === module.id)
+if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
View
@@ -98,5 +98,5 @@ exports.testExplain = function() {
assert.isEqual( 49, c.find(q).limit(-20).explain().get("n"), "11 " );
}
-if (require.main === module.id)
+if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));
View
@@ -1,41 +1,37 @@
var MongoDB = require("mongodb");
var assert = require('test/assert.js');
-var _db = new MongoDB.Mongo( "localhost" ).getDB( "dbbasetest" );
+
+var DB = new MongoDB.Mongo().getDB( "dbbasetest" );
exports.testCreateCollection = function() {
- _db.getCollection( "foo1" ).drop();
- _db.getCollection( "foo2" ).drop();
- _db.getCollection( "foo3" ).drop();
- _db.getCollection( "foo4" ).drop();
-
- var o1 = { "capped": false };
- var c = _db.createCollection("foo1", o1);
-
- /*var o2 = BasicDBObjectBuilder.start().add("capped", true)
- .add("size", 100).get();*/
- var o2 = { "capped": true, "size": 100 }
- c = _db.createCollection("foo2", o2);
- for (var i=0; i<30; i++) {
- c.insert({"x": i});
- }
+ DB.getCollection("foo1").drop();
+ DB.getCollection("foo2").drop();
+ DB.getCollection("foo3").drop();
+ DB.getCollection("foo4").drop();
+
+ var c = DB.createCollection("foo1", { "capped": false });
+
+ c = DB.createCollection("foo2", { "capped": true, "size": 100 });
+ for (var i = 0; i < 30; i++) c.insert({ "x": i });
+
assert.isTrue(c.find().count() < 10);
- var o3 = { "capped": true, "size": 1000, "max": 2 }
- c = _db.createCollection("foo3", o3);
- for (var i=0; i<30; i++) {
- c.insert({"x": i});
- }
- assert.isEqual(c.find().count(), 2);
+ c = DB.createCollection("foo3", {
+ "capped": true,
+ "size": 1000,
+ "max": 2
+ });
+
+ for (var i=0; i<30; i++) c.insert({ "x": i });
+ assert.eq(c.find().count(), 2);
try {
- var o4 = { "capped": true, "size": -20 }
- c = _db.createCollection("foo4", o4);
- }
- catch(e) {
+ DB.createCollection("foo4", { "capped": true, "size": -20 }); // Invalid size
+ } catch(e) {
return;
}
- assert.isEqual(0, 1);
+ assert.eq(0, 1);
}
-if (require.main === module.id)
+if (require.main == module.id)
require("os").exit(require("test/runner").run(exports));

0 comments on commit 329945e

Please sign in to comment.