Permalink
Browse files

Simplifying tests and updating to latest mongoose-subpopulate API

  • Loading branch information...
1 parent b3541bb commit 1780af771bb858b7402e47336b8c3a359f707100 @JoshuaGross committed Oct 28, 2012
Showing with 3 additions and 21 deletions.
  1. +1 −2 test/common.js
  2. +2 −15 test/fixtures/model.js
  3. +0 −4 test/mongoose.js
View
@@ -18,8 +18,7 @@ exports.connectDB = function (callback) {
m = mongooseExtender.db;
callback();
} else {
- m = require('./fixtures/model.js').createMongooseObject()
- m.connect(function () { callback(); });
+ m = require('./fixtures/model.js').createMongooseObject(callback);
}
} else {
callback();
View
@@ -34,25 +34,12 @@ var defineModels = function defineModels (mongoose, callback) {
mongoose.User = mongooseSubpopulate.wrapSchema(mongoose.model('User'));
mongoose.Project = mongooseSubpopulate.wrapSchema(mongoose.model('Project'));
- callback();
+ if (callback) callback();
};
exports.createMongooseObject = function (callback) {
exports.db = mongooseSubpopulate.extendMongoose(require('mongoose'), defineModels);
-
- var connectOrig = exports.db.connect;
- exports.db.connect = function (callback) {
- // TOP SECRET AND STUFF
- // move to a config file?
- if ('test' === process.env.NODE_ENV) {
- return connectOrig('mongodb://localhost/mongoose-subpopulate-test', callback);
- } else {
- throw new Error('This is only meant for testing.');
- }
-
- console.warn('Cannot connect to mongoose, unknown environment', process.env.NODE_ENV);
- };
-
+ exports.db.connect('mongodb://localhost/mongoose-subpopulate-test', callback);
return exports.db;
};
View
@@ -116,7 +116,6 @@ describe('mongoose wrapping of find, exec, etc', function () {
expect(users[i]).to.have.property('_id');
expect(users[i]._id).to.not.be(undefined);
findOneID = users[i]._id;
- console.log(findOneID);
}
done();
});
@@ -155,9 +154,6 @@ describe('mongoose wrapping of find, exec, etc', function () {
});*/
it('should wrap errors from findOne', function (done) {
var m = common.db();
- console.log(findOneID);
- console.log({ _id: findOneID });
- //m.User.findOne({ _id: findOneID }, [], {}, function (user) {
m.User.findOne({ _id: findOneID }, function (user) {
expect(user).to.not.be(undefined);
expect(user).to.not.be(null);

0 comments on commit 1780af7

Please sign in to comment.