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

时间:2017-08-10 21:21:54

标签: mongodb unit-testing meteor collections duplicates

/ *  这是一个现在失败的测试。因为我们打电话给" coffins.import"  一次在服务器测试中,一次在客户端测试中,然后导入  相同的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();
    });

这是我测试失败的结果!

0 个答案:

没有答案