Пример #1
0
   test('remove single link', function(t) {
      t.plan(5);

      db.links.findOne({}, function(err, link) {
         t.error(err, 'get first link');

         agent
            .post('/a/deleteLinks')
            .send({
               from: category,
               linkIds: [link._id]
            })
            .expect(200)
            .expect('Content-Type', 'application/json; charset=utf-8')
            .end(function(err, res) {
               t.error(err, 'delete one link');
               t.equal(res.body.type, 'success', 'received success response');

               db.links.count(function(err, count) {
                  t.error(err, 'count links in category');
                  t.equal(count, CATEGORY_MAX - 1, 'max - 1 links in category');
               });
            });
      });
   });
Пример #2
0
            .end(function(err, res) {
               t.error(err, 'delete one link');
               t.equal(res.body.type, 'success', 'received success response');

               db.links.count(function(err, count) {
                  t.error(err, 'count links in category');
                  t.equal(count, CATEGORY_MAX - 1, 'max - 1 links in category');
               });
            });
Пример #3
0
         .end(function(err, res) {
            t.error(err, 'insert 3/4 new links into frameSize of 1');

            var data = res.body.data;
            t.equal(res.body.type, 'error', 'received error response');

            db.links.count(function(err, count) {
               t.error(err, 'count links');

               t.equal(count, CATEGORY_MAX, 'links at max again');
            });
         });
Пример #4
0
            }).count(function(err, available) {
               t.error(err, 'get non pending links');

               t.ok(available <= CATEGORY_MAX, 'unable to retrieve more than cmax');

               db.links.find({
                  category: db.mongoId(category)
               }).count(function(err, total) {
                  t.error(err, 'get all links from category');
                  t.equal(total, CATEGORY_MAX, 'category is at maximum capacity');
               });
            });
Пример #5
0
               .end(function(err, res) {
                  t.error(err, 'add links with single unique');

                  var data = res.body.data;
                  t.equal(res.body.type, 'success', 'received success response');
                  t.equal(data.valid, 10, 'found 10 valid links');
                  t.equal(data.inserted, 1, 'inserted 1 link');

                  db.links.count(function(err, count) {
                     t.error(err, 'count links');

                     t.equal(count, CATEGORY_MAX, 'links at max again');
                  });
               });
Пример #6
0
   test('add mixed with no overflow', function(t) {
      t.plan(8);

      db.links.find({}).limit(10).toArray(function(err, links) {
         t.error(err, 'get first link');
         db.links.remove({
            _id: links[0]._id
         }, function(err) {
            t.error(err, 'remove first link');
            links.forEach(function(li) {
               delete li._id;
               delete li.owner;
               delete li.category;
               delete li.playcount;
               delete li.other;
               delete li.dateAdded;
            });

            agent
               .post('/a/addManyLinks')
               .send({
                  category: category,
                  links: links
               })
               .expect(200)
               .expect('Content-Type', 'application/json; charset=utf-8')
               .end(function(err, res) {
                  t.error(err, 'add links with single unique');

                  var data = res.body.data;
                  t.equal(res.body.type, 'success', 'received success response');
                  t.equal(data.valid, 10, 'found 10 valid links');
                  t.equal(data.inserted, 1, 'inserted 1 link');

                  db.links.count(function(err, count) {
                     t.error(err, 'count links');

                     t.equal(count, CATEGORY_MAX, 'links at max again');
                  });
               });
         });
      });
   });
Пример #7
0
         .end(function(err, res) {
            t.error(err, 'fill remaining category with 1000 links');

            var data = res.body.data;
            t.equal(res.body.type, 'error', 'received error response');
            db.links.find({
               category: db.mongoId(category),
               pending: {$exists: false}
            }).count(function(err, available) {
               t.error(err, 'get non pending links');

               t.ok(available <= CATEGORY_MAX, 'unable to retrieve more than cmax');

               db.links.find({
                  category: db.mongoId(category)
               }).count(function(err, total) {
                  t.error(err, 'get all links from category');
                  t.equal(total, CATEGORY_MAX, 'category is at maximum capacity');
               });
            });
         });