Permalink
Browse files

add failing test: running validation on query result hangs

  • Loading branch information...
1 parent 76eb1b8 commit 254afd2bfa0ce6959b39b61f074424494971caa1 @aheckmann aheckmann committed Mar 19, 2011
Showing with 29 additions and 0 deletions.
  1. +29 −0 test/model.test.js
View
@@ -652,6 +652,35 @@ module.exports = {
});
});
},
+
+ 'test validation on a query result': function () {
+ mongoose.model('TestValidationOnResult', new Schema({
+ resultv: { type: String, required: true }
+ }));
+
+ var db = start()
+ , TestV = db.model('TestValidationOnResult');
+
+ var post = new TestV;
+
+ post.validate(function (err) {
+ err.should.be.an.instanceof(MongooseError);
+ err.should.be.an.instanceof(ValidatorError);
+
+ post.resultv = 'yeah';
+ post.save(function (err) {
+ should.strictEqual(err, null);
+ TestV.findOne({ _id: post.id }, function (err, found) {
+ should.strictEqual(err, null);
+ found.resultv.should.eql('yeah');
+ found.save(function(err){
+ should.strictEqual(err, null);
+ db.close();
+ })
+ });
+ });
+ })
+ },
'test nested validation': function(){
mongoose.model('TestNestedValidation', new Schema({

0 comments on commit 254afd2

Please sign in to comment.