【发布时间】:2014-12-20 16:18:12
【问题描述】:
我已经阅读了人们在使用版本密钥时遇到的其他问题/答案,但由于某种原因,我不明白为什么在我的情况下会发生这种情况。
所以我有以下摩卡测试:
it('should be able to save one job', function (done) {
Promise.join(user.saveAsync(), company.saveAsync(),
function (savedUser, savedCompany) {
user = savedUser[0];
user.jobs.push(job);
user.saveAsync()
.spread(function (savedUserWithJob) {
user = savedUserWithJob;
user.jobs.should.have.length(1);
done();
})
.catch(function (err) {
done(err);
});
});
});
这一切都很好并且通过了。即使在运行时我也没有任何其他问题。
现在,当我尝试在第一个测试之后再次运行相同的测试时,即:
it('should be able to save one job', function (done) {
.....
});
it('should be able to save one job again', function (done) {
.....
});
第二个失败并出现错误:
版本错误:找不到匹配的文档。
我真的不明白为什么会发生这种情况,因为我已经第一次推送到阵列而没有版本控制问题。为什么连续第二次失败?
【问题讨论】:
标签: node.js mongoose mocha.js bluebird