You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
slight refactor from code review
smoke test large list of commands ported more tests to mocha, some slight cleanup in tests move sinon and uuid to dev dependencies finished porting eval tests over to mocha rebased mocha testing branch with master ported client and script tests ported watch tests ported detect_buffers tests ported unref tests ported auth tests over to mocha ported idle and no_delay tests ported hlen, hset continuing marching forward ported hincrby, sinter, sort, pubsub tests. improved logic in redis-process, I was still occasionally having issues where redis failed to exit. switch back to default test command ported del, exists, hlen, keys, randomkey, type cleanup based on what I've learned so far from refactor. we now start and stop redis less often. moved tests to their final resting place finished porting node_redis client tests ported hgetall, mget, msetnx, rename, renamenx, setex, setnx ported hgetall, mget, msetnx, rename, renamenx, setex, setnx ported queue tests to mocha amalgamated some of the helper logic ported sadd, scard, sismember, srem, utf-8
This commit is contained in:
76
test/commands/keys.spec.js
Normal file
76
test/commands/keys.spec.js
Normal file
@@ -0,0 +1,76 @@
|
||||
var assert = require("assert");
|
||||
var config = require("../lib/config");
|
||||
var crypto = require("crypto");
|
||||
var helper = require("../helper");
|
||||
var redis = config.redis;
|
||||
|
||||
describe("The 'keys' method", function () {
|
||||
|
||||
function allTests(parser, ip) {
|
||||
var args = config.configureClient(parser, ip);
|
||||
|
||||
describe("using " + parser + " and " + ip, function () {
|
||||
var client;
|
||||
|
||||
beforeEach(function (done) {
|
||||
client = redis.createClient.apply(redis.createClient, args);
|
||||
client.once("error", done);
|
||||
client.once("connect", function () {
|
||||
client.flushdb(done);
|
||||
});
|
||||
});
|
||||
|
||||
it('returns matching keys', function (done) {
|
||||
client.mset(["test keys 1", "test val 1", "test keys 2", "test val 2"], helper.isString("OK"));
|
||||
client.KEYS(["test keys*"], function (err, results) {
|
||||
assert.strictEqual(2, results.length);
|
||||
assert.ok(~results.indexOf("test keys 1"));
|
||||
assert.ok(~results.indexOf("test keys 2"));
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('handles a large packet size', function (done) {
|
||||
var keys_values = [];
|
||||
|
||||
for (var i = 0; i < 200; i++) {
|
||||
var key_value = [
|
||||
"multibulk:" + crypto.randomBytes(256).toString("hex"), // use long strings as keys to ensure generation of large packet
|
||||
"test val " + i
|
||||
];
|
||||
keys_values.push(key_value);
|
||||
}
|
||||
|
||||
client.mset(keys_values.reduce(function(a, b) {
|
||||
return a.concat(b);
|
||||
}), helper.isString("OK"));
|
||||
|
||||
client.KEYS("multibulk:*", function(err, results) {
|
||||
assert.deepEqual(keys_values.map(function(val) {
|
||||
return val[0];
|
||||
}).sort(), results.sort());
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('handles an empty response', function (done) {
|
||||
client.KEYS(['users:*'], function (err, results) {
|
||||
assert.strictEqual(results.length, 0);
|
||||
assert.ok(Array.isArray(results));
|
||||
return done(err);
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
client.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