1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Minor changes

Move utility functions in lib/utils.js
Improve the js parser in cases the buffer is incomplete
Rename lib/parser to lib/parsers

Fix smaller issues with test suite and fix parser errors not being catched

Fixed wrong test for the new .end flush parameter
Fixed test suite options being partly mutated
Add some more tests
This commit is contained in:
Ruben Bridgewater
2015-09-25 00:54:16 +02:00
parent ff47dc3ce8
commit 5f261c5823
13 changed files with 212 additions and 102 deletions

View File

@@ -0,0 +1,34 @@
'use strict';
var config = require("../lib/config");
var helper = require("../helper");
var redis = config.redis;
describe("The 'getoadd' method", function () {
helper.allTests(function(parser, ip, args) {
describe("using " + parser + " and " + ip, function () {
var client;
beforeEach(function (done) {
client = redis.createClient.apply(redis.createClient, args);
client.once("connect", function () {
client.flushdb(done);
});
});
it('returns 1 if the key exists', function (done) {
client.geoadd("mycity:21:0:location", "13.361389","38.115556","COR", function(err, res) {
console.log(err, res);
// geoadd is still in the unstable branch. As soon as it reaches the stable one, activate this test
done();
});
});
afterEach(function () {
client.end();
});
});
});
});

View File

@@ -88,6 +88,16 @@ describe("The 'set' method", function () {
});
}, 100);
});
it("sets the value correctly with the array syntax", function (done) {
client.set([key, value]);
setTimeout(function () {
client.get(key, function (err, res) {
helper.isString(value)(err, res);
done();
});
}, 100);
});
});
describe("with undefined 'key' and missing 'value' parameter", function () {

View File

@@ -0,0 +1,43 @@
'use strict';
var assert = require('assert');
var config = require("../lib/config");
var helper = require("../helper");
var redis = config.redis;
describe("The 'sync' method", function () {
helper.allTests(function(parser, ip, args) {
describe("using " + parser + " and " + ip, function () {
var client;
beforeEach(function (done) {
client = redis.createClient.apply(redis.createClient, args);
client.once("connect", function () {
client.flushdb(done);
});
});
// This produces a parser error
// Protocol error, got "K" as reply type byte
// I'm uncertain if this is correct behavior or not
it('try to sync with the server and fail other commands', function (done) {
client.on('error', function(err) {
assert.equal(err.message, 'Protocol error, got "K" as reply type byte');
assert.equal(err.command, 'SET');
done();
});
client.sync(function(err, res) {
assert.equal(err, null);
assert(!!res);
});
client.set('foo', 'bar');
});
afterEach(function () {
client.end();
});
});
});
});