1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/test/commands/incr.spec.js
Benjamin Coe a0832c3744 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
2015-08-14 21:31:18 -07:00

125 lines
4.8 KiB
JavaScript

var async = require('async');
var assert = require('assert');
var config = require("../lib/config");
var helper = require('../helper');
var redis = config.redis;
var uuid = require('uuid');
describe("The 'incr' method", function () {
function allTests(parser, ip) {
var args = config.configureClient(parser, ip);
describe("using " + parser + " and " + ip, function () {
var key = "sequence";
describe("when not connected", function () {
var client;
beforeEach(function (done) {
client = redis.createClient.apply(redis.createClient, args);
client.once("error", done);
client.once("connect", function () {
client.set(key, "9007199254740992", function (err, res) {
helper.isNotError()(err, res);
client.quit();
});
});
client.on('end', function () {
return done();
});
});
afterEach(function () {
client.end();
});
it("reports an error", function (done) {
client.incr(function (err, res) {
assert.equal(err.message, 'Redis connection gone from end event.');
done();
});
});
});
describe("when connected and a value in Redis", function () {
var client;
// Also, why tf were these disabled for hiredis? They work just fine.
before(function (done) {
/*
9007199254740992 -> 9007199254740992
9007199254740993 -> 9007199254740992
9007199254740994 -> 9007199254740994
9007199254740995 -> 9007199254740996
9007199254740996 -> 9007199254740996
9007199254740997 -> 9007199254740996
*/
client = redis.createClient.apply(redis.createClient, args);
client.once("error", done);
client.once("connect", function () {
client.set(key, "9007199254740992", function (err, res) {
helper.isNotError()(err, res);
done();
});
});
});
after(function () {
client.end();
});
it("changes the last digit from 2 to 3", function (done) {
client.incr(key, function (err, res) {
helper.isString("9007199254740993")(err, res);
done(err);
});
});
describe("and we call it again", function () {
it("changes the last digit from 3 to 4", function (done) {
client.incr(key, function (err, res) {
helper.isString("9007199254740994")(err, res);
done(err);
});
});
describe("and again", function () {
it("changes the last digit from 4 to 5", function (done) {
client.incr(key, function (err, res) {
helper.isString("9007199254740995")(err, res);
done(err);
});
});
describe("and again", function () {
it("changes the last digit from 5 to 6", function (done) {
client.incr(key, function (err, res) {
helper.isString("9007199254740996")(err, res);
done(err);
});
});
describe("and again", function () {
it("changes the last digit from 6 to 7", function (done) {
client.incr(key, function (err, res) {
helper.isString("9007199254740997")(err, res);
done(err);
});
});
});
});
});
});
});
});
}
['javascript', 'hiredis'].forEach(function (parser) {
allTests(parser, "/tmp/redis.sock");
['IPv4', 'IPv6'].forEach(function (ip) {
allTests(parser, ip);
})
});
});