You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
finished porting blpop, expire, mset, slowlog, sunionstore, ttl
This commit is contained in:
64
test/commands/blpop.spec.js
Normal file
64
test/commands/blpop.spec.js
Normal file
@@ -0,0 +1,64 @@
|
||||
var assert = require("assert");
|
||||
var config = require("../lib/config");
|
||||
var helper = require("../helper");
|
||||
var redis = config.redis;
|
||||
|
||||
describe("The 'blpop' method", function () {
|
||||
|
||||
function allTests(parser, ip) {
|
||||
var args = config.configureClient(parser, ip);
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
var client;
|
||||
var bclient;
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
client.once("error", done);
|
||||
client.once("connect", function () {
|
||||
client.flushdb(done);
|
||||
});
|
||||
});
|
||||
|
||||
it('pops value immediately if list contains values', function (done) {
|
||||
bclient = redis.createClient.apply(redis.createClient, args);
|
||||
client.rpush("blocking list", "initial value", helper.isNumber(1));
|
||||
bclient.blpop("blocking list", 0, function (err, value) {
|
||||
assert.strictEqual(value[0], "blocking list");
|
||||
assert.strictEqual(value[1], "initial value");
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('waits for value if list is not yet populated', function (done) {
|
||||
bclient = redis.createClient.apply(redis.createClient, args);
|
||||
bclient.blpop("blocking list 2", 5, function (err, value) {
|
||||
assert.strictEqual(value[0], "blocking list 2");
|
||||
assert.strictEqual(value[1], "initial value");
|
||||
return done(err);
|
||||
});
|
||||
client.rpush("blocking list 2", "initial value", helper.isNumber(1));
|
||||
});
|
||||
|
||||
it('times out after specified time', function (done) {
|
||||
bclient = redis.createClient.apply(redis.createClient, args);
|
||||
bclient.BLPOP("blocking list", 1, function (err, res) {
|
||||
assert.strictEqual(res, null);
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
client.end();
|
||||
bclient.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
['javascript', 'hiredis'].forEach(function (parser) {
|
||||
allTests(parser, "/tmp/redis.sock");
|
||||
['IPv4', 'IPv6'].forEach(function (ip) {
|
||||
allTests(parser, ip);
|
||||
})
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user