You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-03 04:01:40 +03:00
Reduce timeouts if possible Extend timeouts if needed (windows tests need their time) Don't expose the redis socket to others than the owner Don't create the stunnel log
96 lines
3.2 KiB
JavaScript
96 lines
3.2 KiB
JavaScript
'use strict';
|
|
|
|
var assert = require('assert');
|
|
var config = require('../lib/config');
|
|
var helper = require('../helper');
|
|
var redis = config.redis;
|
|
var uuid = require('uuid');
|
|
|
|
describe("The 'get' method", function () {
|
|
|
|
helper.allTests(function (parser, ip, args) {
|
|
|
|
describe('using ' + parser + ' and ' + ip, function () {
|
|
var key, value;
|
|
|
|
beforeEach(function () {
|
|
key = uuid.v4();
|
|
value = uuid.v4();
|
|
});
|
|
|
|
describe('when not connected', function () {
|
|
var client;
|
|
|
|
beforeEach(function (done) {
|
|
client = redis.createClient.apply(null, args);
|
|
client.once('ready', function () {
|
|
client.quit();
|
|
});
|
|
client.on('end', done);
|
|
});
|
|
|
|
it('reports an error', function (done) {
|
|
client.get(key, function (err, res) {
|
|
assert(err.message.match(/The connection has already been closed/));
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('reports an error promisified', function () {
|
|
return client.getAsync(key).then(assert, function (err) {
|
|
assert(err.message.match(/The connection has already been closed/));
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when connected', function () {
|
|
var client;
|
|
|
|
beforeEach(function (done) {
|
|
client = redis.createClient.apply(null, args);
|
|
client.once('ready', function () {
|
|
done();
|
|
});
|
|
});
|
|
|
|
afterEach(function () {
|
|
client.end(true);
|
|
});
|
|
|
|
describe('when the key exists in Redis', function () {
|
|
beforeEach(function (done) {
|
|
client.set(key, value, function (err, res) {
|
|
helper.isNotError()(err, res);
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('gets the value correctly', function (done) {
|
|
client.GET(key, function (err, res) {
|
|
helper.isString(value)(err, res);
|
|
done(err);
|
|
});
|
|
});
|
|
|
|
it("should not throw on a get without callback (even if it's not useful)", function (done) {
|
|
client.GET(key);
|
|
client.on('error', function (err) {
|
|
throw err;
|
|
});
|
|
setTimeout(done, 25);
|
|
});
|
|
});
|
|
|
|
describe('when the key does not exist in Redis', function () {
|
|
it('gets a null value', function (done) {
|
|
client.get(key, function (err, res) {
|
|
helper.isNull()(err, res);
|
|
done(err);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|