setRemove tests

v1.18.x
barisusakli 10 years ago
parent adae2bd13e
commit 1e6f5d822d

@ -57,12 +57,6 @@ module.exports = function(app, middleware, controllers) {
});
router.get('/test', function(req, res) {
//res.redirect(404);
var db = require('../database');
db.increment('someDerpKey', function(err, value) {
console.log(err, value);
db.delete('someDerpKey');
res.json('ok');
})
res.redirect(404);
});
};

@ -139,6 +139,50 @@ describe('Set methods', function() {
});
});
describe('setRemove()', function() {
it('should remove a element from set', function(done) {
db.setRemove('testSet', '2', function(err) {
assert.equal(err, null);
assert.equal(arguments.length, 1, 'arguments.length error');
db.isSetMember('testSet', '2', function(err, isMember) {
assert.equal(err, null);
assert.equal(isMember, false);
done();
});
});
});
});
describe('setsRemove()', function() {
it('should remove a element from multiple sets', function(done) {
db.setsRemove(['set1', 'set2'], 'value', function(err) {
assert.equal(err, null);
assert.equal(arguments.length, 1, 'arguments.length error');
db.isMemberOfSets(['set1', 'set2'], 'value', function(err, members) {
assert.equal(err, null);
assert.deepEqual(members, [false, false]);
done();
});
});
});
});
describe('setRemoveRandom()', function() {
it('should remove a random element from set', function(done) {
db.setRemoveRandom('testSet', function(err, element) {
assert.equal(err, null);
assert.equal(arguments.length, 2, 'arguments.length error');
db.isSetMember('testSet', element, function(err, ismember) {
assert.equal(err, null);
assert.equal(ismember, false);
done();
});
});
});
});
after(function() {
db.flushdb();

Loading…
Cancel
Save