Mongodb 如何编写单元测试以确保集合中没有重复项

Mongodb 如何编写单元测试以确保集合中没有重复项,mongodb,unit-testing,meteor,collections,duplicates,Mongodb,Unit Testing,Meteor,Collections,Duplicates,/* 这是一个现在失败的测试。因为我们叫“棺材,进口” 一次在服务器测试中,一次在客户机测试中,他们导入了 同一个csv文件重复两次。我们该怎么办? */ 这是我考试不及格的结果 “单元测试”应该确保为应该是“唯一的”键设置了一个适当的位置。拥有一个唯一的索引将强制执行一开始就不能有重复的索引。当然,一旦你买了,索引就会自己照顾自己。那么“单元测试”应该真正确保为应该是“唯一”的键设置了一个。拥有一个唯一的索引将强制执行一开始就不能有重复的索引。当然,一旦你买了,指数就会自行调整。 it("Th

/* 这是一个现在失败的测试。因为我们叫“棺材,进口” 一次在服务器测试中,一次在客户机测试中,他们导入了 同一个csv文件重复两次。我们该怎么办? */

这是我考试不及格的结果

“单元测试”应该确保为应该是“唯一的”键设置了一个适当的位置。拥有一个唯一的索引将强制执行一开始就不能有重复的索引。当然,一旦你买了,索引就会自己照顾自己。那么“单元测试”应该真正确保为应该是“唯一”的键设置了一个。拥有一个唯一的索引将强制执行一开始就不能有重复的索引。当然,一旦你买了,指数就会自行调整。
it("There should be NO DUPLICATE coffins", function(done) {
        const allCoffins = Coffins.find();
   // What is unique in a coffin? Well, the bib_num is surely unique.
   // So no two coffins should have the same bib_num.
   // make an array of all bib_nums.

        const bib_nums = [];
        allCoffins.forEach(function(coffin){

   // is this coffin's bib_num already in our array? shouldn't be.

        assert.ok(bib_nums.indexOf(coffin.bib_num) === -1, "bib_num should be unique");

  // then put this bib_num in our list

        bib_nums.push(coffin.bib_num);

            console.log(bib_nums);
        });

  // if we got through the list with no assertion failures, its good.

       done();
    });