Skip to content

Commit

Permalink
test(query): repro #8012
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Jul 30, 2019
1 parent 1670ff1 commit f10f621
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/model.findOneAndReplace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,24 @@ describe('model: findOneAndReplace:', function() {
assert.equal(doc.age, 59);
});
});

it('orFail() (gh-8030)', function() {
const schema = Schema({ name: String, age: Number });
const Model = db.model('gh8030', schema);

return co(function*() {
let err = yield Model.findOneAndReplace({}, { name: 'test' }).orFail().
then(() => assert.ok(false), err => err);

assert.ok(err);
assert.equal(err.name, 'DocumentNotFoundError');

yield Model.create({ name: 'test' });
err = yield Model.findOneAndReplace({ name: 'test' }, { name: 'test2' }).
orFail().
then(() => null, err => err);

assert.ifError(err);
});
});
});

0 comments on commit f10f621

Please sign in to comment.