UNPKG

taggable-via-redis

Version:

Add tagging functionality backed by Redis. This is a rewrite of sintaxi's node-redis-tag.

65 lines (56 loc) 1.89 kB
// Generated by CoffeeScript 1.6.3 /* # test for taggabler_via_redis */ (function() { var MODULE_NAME, REDIS_CLIENT, should, taggable; should = require("should"); taggable = require("../taggabler_via_redis"); REDIS_CLIENT = null; MODULE_NAME = "book"; describe("basic find tests", function() { before(function(done) { var redis; redis = require("redis"); REDIS_CLIENT = redis.createClient(); REDIS_CLIENT.flushall(); taggable.init(REDIS_CLIENT); return setTimeout(done, 1800); }); return describe("taggabler_via_redis", function() { it("set things up", function(done) { taggable.set(MODULE_NAME, "thing1", ["foo", "bar", "baz"], function(err) { should.not.exist(err); taggable.set(MODULE_NAME, "thing2", ["foo"], function(err) { should.not.exist(err); taggable.set(MODULE_NAME, "thing3", ["foo", "bar"], function(err) { should.not.exist(err); done(); }); }); }); }); it("should find 3 books from tag foo", function(done) { taggable.find(MODULE_NAME, "foo", function(err, rsp) { should.not.exist(err); rsp.sort().should.containDeep(["thing1", "thing2", "thing3"]); done(); }); }); it("should find 2 books from tag foo and bar", function(done) { taggable.find(MODULE_NAME, ["foo", "bar"], function(err, rsp) { should.not.exist(err); rsp.sort().should.containDeep(["thing1", "thing3"]); done(); }); }); return it("should find 1 books from tag baz", function(done) { taggable.find(MODULE_NAME, "baz", function(err, rsp) { should.not.exist(err); rsp.sort().should.containDeep(["thing1"]); done(); }); }); }); }); }).call(this);