diff --git a/.jshintignore b/.eslintignore similarity index 82% rename from .jshintignore rename to .eslintignore index ed454a5bac..fd16de3088 100644 --- a/.jshintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ node_modules/** coverage/** **.md -**.log \ No newline at end of file +**.log diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000000..75c73341b0 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,108 @@ +env: + node: true + es6: false + +rules: + # Possible Errors + # http://eslint.org/docs/rules/#possible-errors + comma-dangle: [2, "only-multiline"] + no-constant-condition: 2 + no-control-regex: 2 + no-debugger: 2 + no-dupe-args: 2 + no-dupe-keys: 2 + no-duplicate-case: 2 + no-empty: 2 + no-empty-character-class: 2 + no-ex-assign: 2 + no-extra-boolean-cast : 2 + no-extra-parens: [2, "functions"] + no-extra-semi: 2 + no-func-assign: 2 + no-invalid-regexp: 2 + no-irregular-whitespace: 2 + no-negated-in-lhs: 2 + no-obj-calls: 2 + no-regex-spaces: 2 + no-sparse-arrays: 2 + no-inner-declarations: 2 + no-unexpected-multiline: 2 + no-unreachable: 2 + use-isnan: 2 + valid-typeof: 2 + + # Best Practices + # http://eslint.org/docs/rules/#best-practices + array-callback-return: 2 + block-scoped-var: 2 + dot-notation: 2 + eqeqeq: 2 + no-else-return: 2 + no-extend-native: 2 + no-floating-decimal: 2 + no-extra-bind: 2 + no-fallthrough: 2 + no-labels: 2 + no-lone-blocks: 2 + no-loop-func: 2 + no-multi-spaces: 2 + no-multi-str: 2 + no-native-reassign: 2 + no-new-wrappers: 2 + no-octal: 2 + no-proto: 2 + no-redeclare: 2 + no-return-assign: 2 + no-self-assign: 2 + no-self-compare: 2 + no-sequences: 2 + no-throw-literal: 2 + no-useless-call: 2 + no-useless-concat: 2 + no-useless-escape: 2 + no-void: 2 + no-unmodified-loop-condition: 2 + yoda: 2 + + # Strict Mode + # http://eslint.org/docs/rules/#strict-mode + strict: [2, "global"] + + # Variables + # http://eslint.org/docs/rules/#variables + no-delete-var: 2 + no-shadow-restricted-names: 2 + no-undef: 2 + no-unused-vars: [2, {"args": "none"}] + + # http://eslint.org/docs/rules/#nodejs-and-commonjs + no-mixed-requires: 2 + no-new-require: 2 + no-path-concat: 2 + + # Stylistic Issues + # http://eslint.org/docs/rules/#stylistic-issues + comma-spacing: 2 + eol-last: 2 + indent: [2, 4, {SwitchCase: 2}] + keyword-spacing: 2 + max-len: [2, 200, 2] + new-parens: 2 + no-mixed-spaces-and-tabs: 2 + no-multiple-empty-lines: [2, {max: 2}] + no-trailing-spaces: 2 + quotes: [2, "single", "avoid-escape"] + semi: 2 + space-before-blocks: [2, "always"] + space-before-function-paren: [2, "always"] + space-in-parens: [2, "never"] + space-infix-ops: 2 + space-unary-ops: 2 + +globals: + it: true + describe: true + before: true + after: true + beforeEach: true + afterEach: true diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 92441eb976..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,27 +0,0 @@ -{ - "eqeqeq": true, // Prohibits the use of == and != in favor of === and !== - "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee` - "undef": true, // Require all non-global variables be declared before they are used. - "unused": "vars", // Warn unused variables, but not unused params - "strict": true, // Require `use strict` pragma in every file. - "nonbsp": true, // don't allow non utf-8 pages to break - "forin": true, // don't allow not filtert for in loops - "freeze": true, // prohibit overwriting prototypes of native objects - "nonew": true, // prohibit use of constructors with new when not assigning to a variable - "maxdepth": 6, - "latedef": true, - "maxparams": 5, - - // Environment options - "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment. - "mocha": true, - - // Relaxing options - "boss": true, // Accept statements like `while (key = keys.pop()) {}` - - "overrides": { - "examples/*.js": { - "unused": false - } - } -} diff --git a/benchmarks/diff_multi_bench_output.js b/benchmarks/diff_multi_bench_output.js index 6ba8c6900a..dc0d3c227d 100755 --- a/benchmarks/diff_multi_bench_output.js +++ b/benchmarks/diff_multi_bench_output.js @@ -23,11 +23,11 @@ var total_ops = new metrics.Histogram.createUniformHistogram(); console.log('Comparing before,', file1, '(', before_lines.length, 'lines)', 'to after,', file2, '(', after_lines.length, 'lines)'); -function is_whitespace(s) { +function is_whitespace (s) { return !!s.trim(); } -function pad(input, len, chr, right) { +function pad (input, len, chr, right) { var str = input.toString(); chr = chr || ' '; @@ -44,7 +44,7 @@ function pad(input, len, chr, right) { } // green if greater than 0, red otherwise -function humanize_diff(num, unit, toFixed) { +function humanize_diff (num, unit, toFixed) { unit = unit || ''; if (num > 0) { return ' +' + pad(num.toFixed(toFixed || 0) + unit, 7); @@ -52,12 +52,12 @@ function humanize_diff(num, unit, toFixed) { return ' -' + pad(Math.abs(num).toFixed(toFixed || 0) + unit, 7); } -function command_name(words) { +function command_name (words) { var line = words.join(' '); return line.substr(0, line.indexOf(',')); } -before_lines.forEach(function(b, i) { +before_lines.forEach(function (b, i) { var a = after_lines[i]; if (!a || !b || !b.trim() || !a.trim()) { // console.log('#ignored#', '>'+a+'<', '>'+b+'<'); @@ -66,10 +66,10 @@ before_lines.forEach(function(b, i) { var b_words = b.split(' ').filter(is_whitespace); var a_words = a.split(' ').filter(is_whitespace); - var ops = [b_words, a_words].map(function(words) { + var ops = [b_words, a_words].map(function (words) { // console.log(words); return words.slice(-2, -1) | 0; - }).filter(function(num) { + }).filter(function (num) { var isNaN = !num && num !== 0; return !isNaN; }); diff --git a/benchmarks/multi_bench.js b/benchmarks/multi_bench.js index f8b9299564..f13b9bd845 100644 --- a/benchmarks/multi_bench.js +++ b/benchmarks/multi_bench.js @@ -13,7 +13,7 @@ var tests = []; // bluebird.promisifyAll(redis.Multi.prototype); function returnArg (name, def) { - var matches = process.argv.filter(function(entry) { + var matches = process.argv.filter(function (entry) { return entry.indexOf(name + '=') === 0; }); if (matches.length) { @@ -30,7 +30,7 @@ var client_options = { }; var small_str, large_str, small_buf, large_buf, very_large_str, very_large_buf; -function lpad(input, len, chr) { +function lpad (input, len, chr) { var str = input.toString(); chr = chr || ' '; while (str.length < len) { @@ -44,7 +44,7 @@ metrics.Histogram.prototype.print_line = function () { return lpad((obj.min / 1e6).toFixed(2), 6) + '/' + lpad((obj.max / 1e6).toFixed(2), 6) + '/' + lpad((obj.mean / 1e6).toFixed(2), 6); }; -function Test(args) { +function Test (args) { this.args = args; this.callback = null; this.clients = []; @@ -101,7 +101,7 @@ Test.prototype.new_client = function (id) { }); // If no redis server is running, start one - new_client.on('error', function(err) { + new_client.on('error', function (err) { if (err.code === 'CONNECTION_BROKEN') { throw err; } @@ -268,7 +268,7 @@ tests.push(new Test({descr: 'GET 4MiB str', command: 'get', args: ['foo_rand0000 tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], pipeline: 1, client_opts: { return_buffers: true} })); tests.push(new Test({descr: 'GET 4MiB buf', command: 'get', args: ['foo_rand000000000002'], batch: 20, client_opts: { return_buffers: true} })); -function next() { +function next () { var test = tests.shift(); if (test) { test.run(function () { @@ -276,7 +276,7 @@ function next() { }); } else if (rp) { // Stop the redis process if started by the benchmark - rp.stop(function() { + rp.stop(function () { rp = undefined; next(); }); diff --git a/examples/auth.js b/examples/auth.js index c954a4047a..e36b700656 100644 --- a/examples/auth.js +++ b/examples/auth.js @@ -1,7 +1,7 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(); - +var redis = require('redis'); // The client stashes the password and will reauthenticate on every connect. -client.auth('somepass'); +redis.createClient({ + password: 'somepass' +}); diff --git a/examples/backpressure_drain.js b/examples/backpressure_drain.js index f9ab961c33..0e9140c6b2 100644 --- a/examples/backpressure_drain.js +++ b/examples/backpressure_drain.js @@ -1,10 +1,11 @@ 'use strict'; -var redis = require('../index'), - client = redis.createClient(), - remaining_ops = 100000, paused = false; +var redis = require('../index'); +var client = redis.createClient(); +var remaining_ops = 100000; +var paused = false; -function op() { +function op () { if (remaining_ops <= 0) { console.error('Finished.'); process.exit(0); diff --git a/examples/eval.js b/examples/eval.js index 2fbcc42786..cffdb548a1 100644 --- a/examples/eval.js +++ b/examples/eval.js @@ -1,7 +1,7 @@ 'use strict'; -var redis = require('../index'), - client = redis.createClient(); +var redis = require('../index'); +var client = redis.createClient(); client.eval('return 100.5', 0, function (err, res) { console.dir(err); diff --git a/examples/extend.js b/examples/extend.js index c132cebd58..8128b41bdc 100644 --- a/examples/extend.js +++ b/examples/extend.js @@ -1,7 +1,7 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(); +var redis = require('redis'); +var client = redis.createClient(); // Extend the RedisClient prototype to add a custom method // This one converts the results from 'INFO' into a JavaScript Object diff --git a/examples/file.js b/examples/file.js index aff7e1677a..0bacd723b3 100644 --- a/examples/file.js +++ b/examples/file.js @@ -2,13 +2,13 @@ // Read a file from disk, store it in Redis, then read it back from Redis. -var redis = require('redis'), - client = redis.createClient({ - return_buffers: true - }), - fs = require('fs'), - assert = require('assert'), - filename = 'grumpyCat.jpg'; +var redis = require('redis'); +var client = redis.createClient({ + return_buffers: true +}); +var fs = require('fs'); +var assert = require('assert'); +var filename = 'grumpyCat.jpg'; // Get the file I use for testing like this: // curl http://media4.popsugar-assets.com/files/2014/08/08/878/n/1922507/caef16ec354ca23b_thumb_temp_cover_file32304521407524949.xxxlarge/i/Funny-Cat-GIFs.jpg -o grumpyCat.jpg diff --git a/examples/mget.js b/examples/mget.js index 64dd3daa54..e774ac44e0 100644 --- a/examples/mget.js +++ b/examples/mget.js @@ -4,4 +4,4 @@ var client = require('redis').createClient(); client.mget(['sessions started', 'sessions started', 'foo'], function (err, res) { console.dir(res); -}); \ No newline at end of file +}); diff --git a/examples/monitor.js b/examples/monitor.js index 01a2122823..93d5d100f5 100644 --- a/examples/monitor.js +++ b/examples/monitor.js @@ -1,7 +1,7 @@ 'use strict'; -var client = require('../index').createClient(), - util = require('util'); +var client = require('../index').createClient(); +var util = require('util'); client.monitor(function (err, res) { console.log('Entering monitoring mode.'); diff --git a/examples/multi.js b/examples/multi.js index ac7f01b831..e0e3bf13fc 100644 --- a/examples/multi.js +++ b/examples/multi.js @@ -1,7 +1,8 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(), set_size = 20; +var redis = require('redis'); +var client = redis.createClient(); +var set_size = 20; client.sadd('bigset', 'a member'); client.sadd('bigset', 'another member'); diff --git a/examples/multi2.js b/examples/multi2.js index 2071895dff..3a0ceaec6a 100644 --- a/examples/multi2.js +++ b/examples/multi2.js @@ -1,10 +1,10 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(), multi; +var redis = require('redis'); +var client = redis.createClient(); // start a separate command queue for multi -multi = client.multi(); +var multi = client.multi(); multi.incr('incr thing', redis.print); multi.incr('incr other thing', redis.print); diff --git a/examples/psubscribe.js b/examples/psubscribe.js index 65b113cd90..ecd2427404 100644 --- a/examples/psubscribe.js +++ b/examples/psubscribe.js @@ -1,11 +1,11 @@ 'use strict'; -var redis = require('redis'), - client1 = redis.createClient(), - client2 = redis.createClient(), - client3 = redis.createClient(), - client4 = redis.createClient(), - msg_count = 0; +var redis = require('redis'); +var client1 = redis.createClient(); +var client2 = redis.createClient(); +var client3 = redis.createClient(); +var client4 = redis.createClient(); +var msg_count = 0; client1.on('psubscribe', function (pattern, count) { console.log('client1 psubscribed to ' + pattern + ', ' + count + ' total subscriptions'); @@ -23,7 +23,7 @@ client1.on('punsubscribe', function (pattern, count) { }); client1.on('pmessage', function (pattern, channel, message) { - console.log('('+ pattern +')' + ' client1 received message on ' + channel + ': ' + message); + console.log('(' + pattern + ') client1 received message on ' + channel + ': ' + message); msg_count += 1; if (msg_count === 3) { client1.punsubscribe(); diff --git a/examples/pub_sub.js b/examples/pub_sub.js index 8d691126da..d0970eb502 100644 --- a/examples/pub_sub.js +++ b/examples/pub_sub.js @@ -1,8 +1,9 @@ 'use strict'; -var redis = require('redis'), - client1 = redis.createClient(), msg_count = 0, - client2 = redis.createClient(); +var redis = require('redis'); +var client1 = redis.createClient(); +var msg_count = 0; +var client2 = redis.createClient(); // Most clients probably don't do much on 'subscribe'. This example uses it to coordinate things within one program. client1.on('subscribe', function (channel, count) { diff --git a/examples/scan.js b/examples/scan.js index 2f7a9d405a..e6b67ea6ae 100644 --- a/examples/scan.js +++ b/examples/scan.js @@ -1,16 +1,16 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(); +var redis = require('redis'); +var client = redis.createClient(); var cursor = '0'; -function scan() { +function scan () { client.scan( cursor, 'MATCH', 'q:job:*', 'COUNT', '10', - function(err, res) { + function (err, res) { if (err) throw err; // Update the cursor position for the next scan @@ -48,3 +48,4 @@ function scan() { } ); } +scan(); diff --git a/examples/simple.js b/examples/simple.js index 3e67242ddc..2fc2c3aefb 100644 --- a/examples/simple.js +++ b/examples/simple.js @@ -1,7 +1,7 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(); +var redis = require('redis'); +var client = redis.createClient(); client.on('error', function (err) { console.log('error event - ' + client.host + ':' + client.port + ' - ' + err); diff --git a/examples/sort.js b/examples/sort.js index 2181cf3032..b09b06fbbf 100644 --- a/examples/sort.js +++ b/examples/sort.js @@ -1,7 +1,7 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient(); +var redis = require('redis'); +var client = redis.createClient(); client.sadd('mylist', 1); client.sadd('mylist', 2); @@ -16,4 +16,4 @@ client.set('object_2', 'bar'); client.set('object_3', 'qux'); client.sort('mylist', 'by', 'weight_*', 'get', 'object_*', redis.print); -// Prints Reply: qux,foo,bar \ No newline at end of file +// Prints Reply: qux,foo,bar diff --git a/examples/unix_socket.js b/examples/unix_socket.js index 28e5eb0c51..b51aef2d11 100644 --- a/examples/unix_socket.js +++ b/examples/unix_socket.js @@ -1,8 +1,8 @@ 'use strict'; -var redis = require('redis'), - client = redis.createClient('/tmp/redis.sock'), - profiler = require('v8-profiler'); +var redis = require('redis'); +var client = redis.createClient('/tmp/redis.sock'); +var profiler = require('v8-profiler'); client.on('connect', function () { console.log('Got Unix socket connection.'); @@ -18,7 +18,7 @@ setInterval(function () { client.get('space chars'); }, 100); -function done() { +function done () { client.info(function (err, reply) { console.log(reply.toString()); client.quit(); @@ -28,4 +28,5 @@ function done() { setTimeout(function () { console.log('Taking snapshot.'); profiler.takeSnapshot(); + done(); }, 5000); diff --git a/examples/web_server.js b/examples/web_server.js index 6afd0c96f2..ba5950d038 100644 --- a/examples/web_server.js +++ b/examples/web_server.js @@ -2,10 +2,10 @@ // A simple web server that generates dyanmic content based on responses from Redis -var http = require('http'), server, - redis_client = require('redis').createClient(); +var http = require('http'); +var redis_client = require('redis').createClient(); -server = http.createServer(function (request, response) { +http.createServer(function (request, response) { // The server response.writeHead(200, { 'Content-Type': 'text/plain' }); diff --git a/index.js b/index.js index 8e13499cb4..a306cf0100 100644 --- a/index.js +++ b/index.js @@ -620,7 +620,7 @@ RedisClient.prototype.emit_idle = function () { function normal_reply (self, reply) { var command_obj = self.command_queue.shift(); if (typeof command_obj.callback === 'function') { - if ('exec' !== command_obj.command) { + if (command_obj.command !== 'exec') { reply = self.handle_reply(reply, command_obj.command, command_obj.buffer_args); } command_obj.callback(null, reply); @@ -935,7 +935,7 @@ RedisClient.prototype.end = function (flush) { ); } // Clear retry_timer - if (this.retry_timer){ + if (this.retry_timer) { clearTimeout(this.retry_timer); this.retry_timer = null; } diff --git a/lib/command.js b/lib/command.js index 20b7589db2..e4467fb55d 100644 --- a/lib/command.js +++ b/lib/command.js @@ -2,7 +2,7 @@ // This Command constructor is ever so slightly faster than using an object literal, but more importantly, using // a named constructor helps it show up meaningfully in the V8 CPU profiler and in heap snapshots. -function Command(command, args, callback) { +function Command (command, args, callback) { this.command = command; this.args = args; // We only need the args for the offline commands => move them into another class. We need the number of args though for pub sub this.buffer_args = false; @@ -10,7 +10,7 @@ function Command(command, args, callback) { this.sub_commands_left = args.length; } -function OfflineCommand(command, args, callback) { +function OfflineCommand (command, args, callback) { this.command = command; this.args = args; this.callback = callback; diff --git a/lib/multi.js b/lib/multi.js index 5a06e1096a..4d9834378b 100644 --- a/lib/multi.js +++ b/lib/multi.js @@ -3,7 +3,7 @@ var Queue = require('double-ended-queue'); var utils = require('./utils'); -function Multi(client, args) { +function Multi (client, args) { this._client = client; this.queue = new Queue(); var command, tmp_args; @@ -147,7 +147,7 @@ Multi.prototype.exec_transaction = function exec_transaction (callback) { pipeline_transaction_command(self, command, args[1], index, cb); } - self._client.send_command('exec', [], function(err, replies) { + self._client.send_command('exec', [], function (err, replies) { multi_callback(self, err, replies); }); self._client.uncork(); @@ -173,7 +173,6 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct var len = self.queue.length; var index = 0; var args; - var args_len = 1; var callback_without_own_cb = function (err, res) { if (err) { self.results.push(err); @@ -203,7 +202,6 @@ Multi.prototype.exec = Multi.prototype.EXEC = Multi.prototype.exec_batch = funct while (args = self.queue.shift()) { var command = args[0]; var cb; - args_len = args[1].length - 1; if (typeof args[2] === 'function') { cb = batch_callback(self, args[2], index); } else { diff --git a/lib/utils.js b/lib/utils.js index b1b46c7829..61e9a64f75 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -2,7 +2,7 @@ // hgetall converts its replies to an Object. If the reply is empty, null is returned. // These function are only called with internal data and have therefor always the same instanceof X -function replyToObject(reply) { +function replyToObject (reply) { // The reply might be a string or a buffer if this is called in a transaction (multi) if (reply.length === 0 || !(reply instanceof Array)) { return null; @@ -14,7 +14,7 @@ function replyToObject(reply) { return obj; } -function replyToStrings(reply) { +function replyToStrings (reply) { if (reply instanceof Buffer) { return reply.toString(); } diff --git a/package.json b/package.json index e53574749a..7e4d234867 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "benchmark": "node benchmarks/multi_bench.js", "test": "nyc --cache mocha ./test/*.js ./test/commands/*.js --timeout=8000", "pretest": "optional-dev-dependency hiredis", - "posttest": "jshint ." + "posttest": "eslint . --fix" }, "dependencies": { "double-ended-queue": "^2.1.0-0", @@ -36,7 +36,7 @@ "bluebird": "^3.0.2", "coveralls": "^2.11.2", "intercept-stdout": "~0.1.2", - "jshint": "^2.8.0", + "eslint": "^2.5.0", "metrics": "^0.1.9", "mocha": "^2.3.2", "nyc": "^6.0.0", diff --git a/test/auth.spec.js b/test/auth.spec.js index cb78e2ee65..fd79b36845 100644 --- a/test/auth.spec.js +++ b/test/auth.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; @@ -10,7 +10,7 @@ if (process.platform === 'win32') { return; } -describe("client authentication", function () { +describe('client authentication', function () { before(function (done) { helper.stopRedis(function () { helper.startRedis('./conf/password.conf', done); @@ -19,9 +19,9 @@ describe("client authentication", function () { helper.allTests({ allConnections: true - }, function(parser, ip, args) { + }, function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var auth = 'porkchopsandwiches'; var client = null; @@ -40,7 +40,7 @@ describe("client authentication", function () { client = redis.createClient.apply(null, args); client.auth(auth, function (err, res) { assert.strictEqual(null, err); - assert.strictEqual("OK", res.toString()); + assert.strictEqual('OK', res.toString()); return done(err); }); }); @@ -67,7 +67,7 @@ describe("client authentication", function () { }; }); - it("emits error when auth is bad without callback", function (done) { + it('emits error when auth is bad without callback', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client = redis.createClient.apply(null, args); @@ -81,7 +81,7 @@ describe("client authentication", function () { client.auth(auth + 'bad'); }); - it("returns an error when auth is bad (empty string) with a callback", function (done) { + it('returns an error when auth is bad (empty string) with a callback', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client = redis.createClient.apply(null, args); @@ -99,7 +99,7 @@ describe("client authentication", function () { var end = helper.callFuncAfter(done, 2); client = redis.createClient('redis://:' + auth + '@' + config.HOST[ip] + ':' + config.PORT); - client.on("ready", function () { + client.on('ready', function () { end(); }); // The info command may be used while loading but not if not yet authenticated @@ -116,7 +116,7 @@ describe("client authentication", function () { assert.strictEqual(client.options.db, '2'); assert.strictEqual(client.options.password, auth); assert.strictEqual(client.auth_pass, auth); - client.on("ready", function () { + client.on('ready', function () { // Set a key so the used database is returned in the info command client.set('foo', 'bar'); client.get('foo'); @@ -137,7 +137,7 @@ describe("client authentication", function () { auth_pass: auth }); client = redis.createClient.apply(null, args); - client.on("ready", done); + client.on('ready', done); }); it('allows auth and no_ready_check to be provided as config option for client', function (done) { @@ -148,7 +148,7 @@ describe("client authentication", function () { no_ready_check: true }); client = redis.createClient.apply(null, args); - client.on("ready", done); + client.on('ready', done); }); it('allows auth to be provided post-hoc with auth method', function (done) { @@ -157,7 +157,7 @@ describe("client authentication", function () { var args = config.configureClient(parser, ip); client = redis.createClient.apply(null, args); client.auth(auth); - client.on("ready", done); + client.on('ready', done); }); it('reconnects with appropriate authentication', function (done) { @@ -165,7 +165,7 @@ describe("client authentication", function () { client = redis.createClient.apply(null, args); client.auth(auth); - client.on("ready", function () { + client.on('ready', function () { if (this.times_connected === 1) { client.stream.destroy(); } else { @@ -182,7 +182,7 @@ describe("client authentication", function () { client = redis.createClient.apply(null, args); var async = true; - client.auth(undefined, function(err, res) { + client.auth(undefined, function (err, res) { assert.strictEqual(err.message, 'ERR invalid password'); assert.strictEqual(err.command, 'AUTH'); assert.strictEqual(res, undefined); @@ -211,7 +211,7 @@ describe("client authentication", function () { auth_pass: auth }); client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { client.auth(auth, helper.isString('OK', done)); }); }); @@ -223,7 +223,7 @@ describe("client authentication", function () { no_ready_check: true }); client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { client.set('foo', 'bar', function (err, res) { assert.equal(err.message, 'NOAUTH Authentication required.'); assert.equal(err.code, 'NOAUTH'); @@ -236,7 +236,7 @@ describe("client authentication", function () { it('does not allow auth to be provided post-hoc with auth method if not authenticated before', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client = redis.createClient.apply(null, args); - client.on("error", function (err) { + client.on('error', function (err) { assert.equal(err.code, 'NOAUTH'); assert.equal(err.message, 'Ready check failed: NOAUTH Authentication required.'); assert.equal(err.command, 'INFO'); @@ -250,7 +250,7 @@ describe("client authentication", function () { password: 'wrong_password', parser: parser }); - client.once("error", function (err) { + client.once('error', function (err) { assert.strictEqual(err.message, 'ERR invalid password'); done(); }); diff --git a/test/batch.spec.js b/test/batch.spec.js index 5a1ace4e7d..2d02c371f1 100644 --- a/test/batch.spec.js +++ b/test/batch.spec.js @@ -1,35 +1,28 @@ 'use strict'; var assert = require('assert'); -var config = require("./lib/config"); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; -var uuid = require('uuid'); describe("The 'batch' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { - var key, value; + describe('using ' + parser + ' and ' + ip, function () { - beforeEach(function () { - key = uuid.v4(); - value = uuid.v4(); - }); - - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("connect", function () { + client.once('connect', function () { client.quit(); }); client.on('end', done); }); - it("returns an empty array", function (done) { + it('returns an empty array', function (done) { var batch = client.batch(); batch.exec(function (err, res) { assert.strictEqual(err, null); @@ -38,19 +31,19 @@ describe("The 'batch' method", function () { }); }); - it("returns an empty array if promisified", function () { - return client.batch().execAsync().then(function(res) { + it('returns an empty array if promisified', function () { + return client.batch().execAsync().then(function (res) { assert.strictEqual(res.length, 0); }); }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(function (err) { return done(err); }); @@ -61,7 +54,7 @@ describe("The 'batch' method", function () { client.end(true); }); - it("returns an empty array and keep the execution order in takt", function (done) { + it('returns an empty array and keep the execution order in takt', function (done) { var called = false; client.set('foo', 'bar', function (err, res) { called = true; @@ -75,19 +68,19 @@ describe("The 'batch' method", function () { }); }); - it("runs normal calls inbetween batch", function (done) { + it('runs normal calls inbetween batch', function (done) { var batch = client.batch(); - batch.set("m1", "123"); + batch.set('m1', '123'); client.set('m2', '456', done); }); - it("returns an empty array if promisified", function () { - return client.batch().execAsync().then(function(res) { + it('returns an empty array if promisified', function () { + return client.batch().execAsync().then(function (res) { assert.strictEqual(res.length, 0); }); }); - it("returns an empty result array", function (done) { + it('returns an empty result array', function (done) { var batch = client.batch(); var async = true; var notBuffering = batch.exec(function (err, res) { @@ -103,18 +96,18 @@ describe("The 'batch' method", function () { it('fail individually when one command fails using chaining notation', function (done) { var batch1, batch2; batch1 = client.batch(); - batch1.mset("batchfoo", "10", "batchbar", "20", helper.isString("OK")); + batch1.mset('batchfoo', '10', 'batchbar', '20', helper.isString('OK')); // Provoke an error at queue time - batch1.set("foo2", helper.isError()); - batch1.incr("batchfoo"); - batch1.incr("batchbar"); + batch1.set('foo2', helper.isError()); + batch1.incr('batchfoo'); + batch1.incr('batchbar'); batch1.exec(function () { // Confirm that the previous command, while containing an error, still worked. batch2 = client.batch(); batch2.get('foo2', helper.isNull()); - batch2.incr("batchbar", helper.isNumber(22)); - batch2.incr("batchfoo", helper.isNumber(12)); + batch2.incr('batchbar', helper.isNumber(22)); + batch2.incr('batchfoo', helper.isNumber(12)); batch2.exec(function (err, replies) { assert.strictEqual(null, replies[0]); assert.strictEqual(22, replies[1]); @@ -130,12 +123,12 @@ describe("The 'batch' method", function () { done(err); }); batch1 = client.batch(); - batch1.mset("batchfoo", "10", "batchbar", "20", helper.isString("OK")); + batch1.mset('batchfoo', '10', 'batchbar', '20', helper.isString('OK')); // Provoke an error at queue time - batch1.set("foo2"); - batch1.incr("batchfoo"); - batch1.incr("batchbar"); + batch1.set('foo2'); + batch1.incr('batchfoo'); + batch1.incr('batchbar'); batch1.exec(function (err, res) { assert.strictEqual(res[1].command, 'SET'); assert.strictEqual(res[1].code, 'ERR'); @@ -146,45 +139,45 @@ describe("The 'batch' method", function () { it('fail individually when one command in an array of commands fails', function (done) { // test nested batch-bulk replies client.batch([ - ["mget", "batchfoo", "batchbar", function (err, res) { + ['mget', 'batchfoo', 'batchbar', function (err, res) { assert.strictEqual(2, res.length); assert.strictEqual(0, +res[0]); assert.strictEqual(0, +res[1]); }], - ["set", "foo2", helper.isError()], - ["incr", "batchfoo"], - ["incr", "batchbar"] + ['set', 'foo2', helper.isError()], + ['incr', 'batchfoo'], + ['incr', 'batchbar'] ]).exec(function (err, replies) { assert.strictEqual(2, replies[0].length); assert.strictEqual(null, replies[0][0]); assert.strictEqual(null, replies[0][1]); assert.strictEqual('SET', replies[1].command); - assert.strictEqual("1", replies[2].toString()); - assert.strictEqual("1", replies[3].toString()); + assert.strictEqual('1', replies[2].toString()); + assert.strictEqual('1', replies[3].toString()); return done(); }); }); it('handles multiple operations being applied to a set', function (done) { - client.sadd("some set", "mem 1"); - client.sadd(["some set", "mem 2"]); - client.sadd("some set", "mem 3"); - client.sadd("some set", "mem 4"); + client.sadd('some set', 'mem 1'); + client.sadd(['some set', 'mem 2']); + client.sadd('some set', 'mem 3'); + client.sadd('some set', 'mem 4'); // make sure empty mb reply works - client.del("some missing set"); - client.smembers("some missing set", function (err, reply) { + client.del('some missing set'); + client.smembers('some missing set', function (err, reply) { // make sure empty mb reply works assert.strictEqual(0, reply.length); }); // test nested batch-bulk replies with empty mb elements. client.BATCH([ - ["smembers", ["some set"]], - ["del", "some set"], - ["smembers", "some set", undefined] // The explicit undefined is handled as a callback that is undefined + ['smembers', ['some set']], + ['del', 'some set'], + ['smembers', 'some set', undefined] // The explicit undefined is handled as a callback that is undefined ]) - .scard("some set") + .scard('some set') .exec(function (err, replies) { assert.strictEqual(4, replies[0].length); assert.strictEqual(0, replies[2].length); @@ -194,26 +187,26 @@ describe("The 'batch' method", function () { it('allows multiple operations to be performed using constructor with all kinds of syntax', function (done) { var now = Date.now(); - var arr = ["batchhmset", "batchbar", "batchbaz"]; + var arr = ['batchhmset', 'batchbar', 'batchbaz']; var arr2 = ['some manner of key', 'otherTypes']; - var arr3 = [5768, "batchbarx", "batchfoox"]; - var arr4 = ["mset", [578, "batchbar"], helper.isString('OK')]; + var arr3 = [5768, 'batchbarx', 'batchfoox']; + var arr4 = ['mset', [578, 'batchbar'], helper.isString('OK')]; client.batch([ arr4, - [["mset", "batchfoo2", "batchbar2", "batchfoo3", "batchbar3"], helper.isString('OK')], - ["hmset", arr], - [["hmset", "batchhmset2", "batchbar2", "batchfoo3", "batchbar3", "test"], helper.isString('OK')], - ["hmset", ["batchhmset", "batchbar", "batchfoo"], helper.isString('OK')], - ["hmset", arr3, helper.isString('OK')], - ['hmset', now, {123456789: "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}], - ['hmset', 'key2', {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 999}, helper.isString('OK')], - ["HMSET", "batchhmset", ["batchbar", "batchbaz"]], - ["hmset", "batchhmset", ["batchbar", "batchbaz"], helper.isString('OK')], + [['mset', 'batchfoo2', 'batchbar2', 'batchfoo3', 'batchbar3'], helper.isString('OK')], + ['hmset', arr], + [['hmset', 'batchhmset2', 'batchbar2', 'batchfoo3', 'batchbar3', 'test'], helper.isString('OK')], + ['hmset', ['batchhmset', 'batchbar', 'batchfoo'], helper.isString('OK')], + ['hmset', arr3, helper.isString('OK')], + ['hmset', now, {123456789: 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}], + ['hmset', 'key2', {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 999}, helper.isString('OK')], + ['HMSET', 'batchhmset', ['batchbar', 'batchbaz']], + ['hmset', 'batchhmset', ['batchbar', 'batchbaz'], helper.isString('OK')], ]) .hmget(now, 123456789, 'otherTypes') - .hmget('key2', arr2, function noop() {}) + .hmget('key2', arr2, function noop () {}) .hmget(['batchhmset2', 'some manner of key', 'batchbar3']) - .mget('batchfoo2', ['batchfoo3', 'batchfoo'], function(err, res) { + .mget('batchfoo2', ['batchfoo3', 'batchfoo'], function (err, res) { assert.strictEqual(res[0], 'batchbar2'); assert.strictEqual(res[1], 'batchbar3'); assert.strictEqual(res[2], null); @@ -235,7 +228,7 @@ describe("The 'batch' method", function () { }); }); - it('converts a non string key to a string', function(done) { + it('converts a non string key to a string', function (done) { // TODO: Converting the key might change soon again. client.batch().hmset(true, { test: 123, @@ -243,8 +236,8 @@ describe("The 'batch' method", function () { }).exec(done); }); - it('runs a batch without any further commands', function(done) { - var buffering = client.batch().exec(function(err, res) { + it('runs a batch without any further commands', function (done) { + var buffering = client.batch().exec(function (err, res) { assert.strictEqual(err, null); assert.strictEqual(res.length, 0); done(); @@ -252,7 +245,7 @@ describe("The 'batch' method", function () { assert(typeof buffering === 'boolean'); }); - it('runs a batch without any further commands and without callback', function() { + it('runs a batch without any further commands and without callback', function () { var buffering = client.batch().exec(); assert.strictEqual(buffering, true); }); @@ -310,8 +303,8 @@ describe("The 'batch' method", function () { it('allows an array to be provided indicating multiple operations to perform', function (done) { // test nested batch-bulk replies with nulls. client.batch([ - ["mget", ["batchfoo", "some", "random value", "keys"]], - ["incr", "batchfoo"] + ['mget', ['batchfoo', 'some', 'random value', 'keys']], + ['incr', 'batchfoo'] ]) .exec(function (err, replies) { assert.strictEqual(replies.length, 2); @@ -322,19 +315,19 @@ describe("The 'batch' method", function () { it('allows multiple operations to be performed on a hash', function (done) { client.batch() - .hmset("batchhash", "a", "foo", "b", 1) - .hmset("batchhash", { - extra: "fancy", - things: "here" + .hmset('batchhash', 'a', 'foo', 'b', 1) + .hmset('batchhash', { + extra: 'fancy', + things: 'here' }) - .hgetall("batchhash") + .hgetall('batchhash') .exec(done); }); - it("should work without any callback or arguments", function (done) { + it('should work without any callback or arguments', function (done) { var batch = client.batch(); - batch.set("baz", "binary"); - batch.set("foo", "bar"); + batch.set('baz', 'binary'); + batch.set('foo', 'bar'); batch.ping(); batch.exec(); diff --git a/test/commands/blpop.spec.js b/test/commands/blpop.spec.js index bf081233b8..d68521e6b5 100644 --- a/test/commands/blpop.spec.js +++ b/test/commands/blpop.spec.js @@ -1,22 +1,22 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; var intercept = require('intercept-stdout'); describe("The 'blpop' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var bclient; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -25,44 +25,44 @@ describe("The 'blpop' method", function () { bclient = redis.createClient.apply(null, args); redis.debug_mode = true; var text = ''; - var unhookIntercept = intercept(function(data) { + var unhookIntercept = intercept(function (data) { text += data; return ''; }); - client.rpush("blocking list", "initial value", helper.isNumber(1)); + client.rpush('blocking list', 'initial value', helper.isNumber(1)); unhookIntercept(); assert(/^Send 127\.0\.0\.1:6379 id [0-9]+: \*3\r\n\$5\r\nrpush\r\n\$13\r\nblocking list\r\n\$13\r\ninitial value\r\n\n$/.test(text)); redis.debug_mode = false; - bclient.blpop("blocking list", 0, function (err, value) { - assert.strictEqual(value[0], "blocking list"); - assert.strictEqual(value[1], "initial value"); + bclient.blpop('blocking list', 0, function (err, value) { + assert.strictEqual(value[0], 'blocking list'); + assert.strictEqual(value[1], 'initial value'); return done(err); }); }); it('pops value immediately if list contains values using array notation', function (done) { bclient = redis.createClient.apply(null, 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"); + 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(null, args); - bclient.blpop("blocking list 2", 5, function (err, value) { - assert.strictEqual(value[0], "blocking list 2"); - assert.strictEqual(value[1], "initial value"); + 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)); + client.rpush('blocking list 2', 'initial value', helper.isNumber(1)); }); it('times out after specified time', function (done) { bclient = redis.createClient.apply(null, args); - bclient.BLPOP("blocking list", 1, function (err, res) { + bclient.BLPOP('blocking list', 1, function (err, res) { assert.strictEqual(res, null); return done(err); }); diff --git a/test/commands/client.spec.js b/test/commands/client.spec.js index 661f70d0be..d73c5036aa 100644 --- a/test/commands/client.spec.js +++ b/test/commands/client.spec.js @@ -1,21 +1,21 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'client' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { var pattern = /addr=/; - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -26,18 +26,18 @@ describe("The 'client' method", function () { describe('list', function () { it('lists connected clients', function (done) { - client.client("LIST", helper.match(pattern, done)); + client.client('LIST', helper.match(pattern, done)); }); it("lists connected clients when invoked with multi's chaining syntax", function (done) { - client.multi().client("list").exec(function(err, results) { + client.multi().client('list').exec(function (err, results) { assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString()); return done(); }); }); - it("lists connected clients when invoked with array syntax on client", function (done) { - client.multi().client(["list"]).exec(function(err, results) { + it('lists connected clients when invoked with array syntax on client', function (done) { + client.multi().client(['list']).exec(function (err, results) { assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString()); return done(); }); @@ -46,7 +46,7 @@ describe("The 'client' method", function () { it("lists connected clients when invoked with multi's array syntax", function (done) { client.multi([ ['client', 'list'] - ]).exec(function(err, results) { + ]).exec(function (err, results) { assert(pattern.test(results[0]), "expected string '" + results + "' to match " + pattern.toString()); return done(); }); @@ -58,7 +58,7 @@ describe("The 'client' method", function () { beforeEach(function (done) { client2 = redis.createClient.apply(redis.createClient, args); - client2.once("ready", function () { + client2.once('ready', function () { done(); }); }); @@ -72,14 +72,14 @@ describe("The 'client' method", function () { // per chunk. So the execution order is only garanteed on each client var end = helper.callFuncAfter(done, 2); - client.client("setname", "RUTH", helper.isString('OK')); - client2.client("setname", "RENEE", helper.isString('OK')); - client2.client("setname", "MARTIN", helper.isString('OK')); - client2.client("getname", function(err, res) { + client.client('setname', 'RUTH', helper.isString('OK')); + client2.client('setname', 'RENEE', helper.isString('OK')); + client2.client('setname', 'MARTIN', helper.isString('OK')); + client2.client('getname', function (err, res) { assert.equal(res, 'MARTIN'); end(); }); - client.client("getname", function(err, res) { + client.client('getname', function (err, res) { assert.equal(res, 'RUTH'); end(); }); diff --git a/test/commands/dbsize.spec.js b/test/commands/dbsize.spec.js index 0bc922c2f3..b1a3d3c32e 100644 --- a/test/commands/dbsize.spec.js +++ b/test/commands/dbsize.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; var uuid = require('uuid'); describe("The 'dbsize' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, value; beforeEach(function () { @@ -18,18 +18,18 @@ describe("The 'dbsize' method", function () { value = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.dbsize([], function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -37,14 +37,14 @@ describe("The 'dbsize' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(function (err, res) { - helper.isString("OK")(err, res); + helper.isString('OK')(err, res); done(); }); }); @@ -54,22 +54,22 @@ describe("The 'dbsize' method", function () { client.end(true); }); - it("returns a zero db size", function (done) { + it('returns a zero db size', function (done) { client.DBSIZE([], function (err, res) { helper.isNotError()(err, res); helper.isType.number()(err, res); - assert.strictEqual(res, 0, "Initial db size should be 0"); + assert.strictEqual(res, 0, 'Initial db size should be 0'); done(); }); }); - describe("when more data is added to Redis", function () { + describe('when more data is added to Redis', function () { var oldSize; beforeEach(function (done) { client.dbsize(function (err, res) { helper.isType.number()(err, res); - assert.strictEqual(res, 0, "Initial db size should be 0"); + assert.strictEqual(res, 0, 'Initial db size should be 0'); oldSize = res; @@ -80,11 +80,11 @@ describe("The 'dbsize' method", function () { }); }); - it("returns a larger db size", function (done) { + it('returns a larger db size', function (done) { client.dbsize([], function (err, res) { helper.isNotError()(err, res); helper.isType.positiveNumber()(err, res); - assert.strictEqual(true, (oldSize < res), "Adding data should increase db size."); + assert.strictEqual(true, (oldSize < res), 'Adding data should increase db size.'); done(); }); }); diff --git a/test/commands/del.spec.js b/test/commands/del.spec.js index 99f3e8fcae..970d0886c4 100644 --- a/test/commands/del.spec.js +++ b/test/commands/del.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'del' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/eval.spec.js b/test/commands/eval.spec.js index 2fdd7857d5..731d656d54 100644 --- a/test/commands/eval.spec.js +++ b/test/commands/eval.spec.js @@ -1,22 +1,22 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var crypto = require("crypto"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var crypto = require('crypto'); +var helper = require('../helper'); var redis = config.redis; describe("The 'eval' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var source = "return redis.call('set', 'sha', 'test')"; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -26,7 +26,7 @@ describe("The 'eval' method", function () { }); it('converts a float to an integer when evaluated', function (done) { - client.eval("return 100.5", 0, helper.isNumber(100, done)); + client.eval('return 100.5', 0, helper.isNumber(100, done)); }); it('returns a string', function (done) { @@ -34,11 +34,11 @@ describe("The 'eval' method", function () { }); it('converts boolean true to integer 1', function (done) { - client.eval("return true", 0, helper.isNumber(1, done)); + client.eval('return true', 0, helper.isNumber(1, done)); }); it('converts boolean false to null', function (done) { - client.eval("return false", 0, helper.isNull(done)); + client.eval('return false', 0, helper.isNull(done)); }); it('converts lua status code to string representation', function (done) { @@ -46,7 +46,7 @@ describe("The 'eval' method", function () { }); it('converts lua error to an error response', function (done) { - client.eval("return {err='this is an error'}", 0, function(err) { + client.eval("return {err='this is an error'}", 0, function (err) { assert(err.code === undefined); helper.isError()(err); done(); @@ -59,7 +59,7 @@ describe("The 'eval' method", function () { assert.strictEqual(1, res[0]); assert.strictEqual(2, res[1]); assert.strictEqual(3, res[2]); - assert.strictEqual("ciao", res[3]); + assert.strictEqual('ciao', res[3]); assert.strictEqual(2, res[4].length); assert.strictEqual(1, res[4][0]); assert.strictEqual(2, res[4][1]); @@ -68,23 +68,23 @@ describe("The 'eval' method", function () { }); it('populates keys and argv correctly', function (done) { - client.eval("return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d", function (err, res) { + client.eval('return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'a', 'b', 'c', 'd', function (err, res) { assert.strictEqual(4, res.length); - assert.strictEqual("a", res[0]); - assert.strictEqual("b", res[1]); - assert.strictEqual("c", res[2]); - assert.strictEqual("d", res[3]); + assert.strictEqual('a', res[0]); + assert.strictEqual('b', res[1]); + assert.strictEqual('c', res[2]); + assert.strictEqual('d', res[3]); return done(); }); }); it('allows arguments to be provided in array rather than as multiple parameters', function (done) { - client.eval(["return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}", 2, "a", "b", "c", "d"], function (err, res) { + client.eval(['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'a', 'b', 'c', 'd'], function (err, res) { assert.strictEqual(4, res.length); - assert.strictEqual("a", res[0]); - assert.strictEqual("b", res[1]); - assert.strictEqual("c", res[2]); - assert.strictEqual("d", res[3]); + assert.strictEqual('a', res[0]); + assert.strictEqual('b', res[1]); + assert.strictEqual('c', res[2]); + assert.strictEqual('d', res[3]); return done(); }); }); @@ -113,7 +113,7 @@ describe("The 'eval' method", function () { it('emit an error if SHA does not exist without any callback', function (done) { client.evalsha('ffffffffffffffffffffffffffffffffffffffff', 0); - client.on('error', function(err) { + client.on('error', function (err) { assert.equal(err.code, 'NOSCRIPT'); assert(/NOSCRIPT No matching script. Please use EVAL./.test(err.message)); done(); @@ -130,11 +130,11 @@ describe("The 'eval' method", function () { }); it('allows a key to be incremented, and performs appropriate conversion from LUA type', function (done) { - client.set("incr key", 0, function (err, reply) { + client.set('incr key', 0, function (err, reply) { if (err) return done(err); - client.eval("local foo = redis.call('incr','incr key')\n" + "return {type(foo),foo}", 0, function (err, res) { + client.eval("local foo = redis.call('incr','incr key')\nreturn {type(foo),foo}", 0, function (err, res) { assert.strictEqual(2, res.length); - assert.strictEqual("number", res[0]); + assert.strictEqual('number', res[0]); assert.strictEqual(1, res[1]); return done(err); }); @@ -142,11 +142,11 @@ describe("The 'eval' method", function () { }); it('allows a bulk operation to be performed, and performs appropriate conversion from LUA type', function (done) { - client.set("bulk reply key", "bulk reply value", function (err, res) { + client.set('bulk reply key', 'bulk reply value', function (err, res) { client.eval("local foo = redis.call('get','bulk reply key'); return {type(foo),foo}", 0, function (err, res) { assert.strictEqual(2, res.length); - assert.strictEqual("string", res[0]); - assert.strictEqual("bulk reply value", res[1]); + assert.strictEqual('string', res[0]); + assert.strictEqual('bulk reply value', res[1]); return done(err); }); }); @@ -154,18 +154,18 @@ describe("The 'eval' method", function () { it('allows a multi mulk operation to be performed, with the appropriate type conversion', function (done) { client.multi() - .del("mylist") - .rpush("mylist", "a") - .rpush("mylist", "b") - .rpush("mylist", "c") + .del('mylist') + .rpush('mylist', 'a') + .rpush('mylist', 'b') + .rpush('mylist', 'c') .exec(function (err, replies) { if (err) return done(err); client.eval("local foo = redis.call('lrange','mylist',0,-1); return {type(foo),foo[1],foo[2],foo[3],# foo}", 0, function (err, res) { assert.strictEqual(5, res.length); - assert.strictEqual("table", res[0]); - assert.strictEqual("a", res[1]); - assert.strictEqual("b", res[2]); - assert.strictEqual("c", res[3]); + assert.strictEqual('table', res[0]); + assert.strictEqual('a', res[1]); + assert.strictEqual('b', res[2]); + assert.strictEqual('c', res[3]); assert.strictEqual(3, res[4]); return done(err); }); @@ -175,31 +175,31 @@ describe("The 'eval' method", function () { it('returns an appropriate representation of Lua status reply', function (done) { client.eval("local foo = redis.call('set','mykey','myval'); return {type(foo),foo['ok']}", 0, function (err, res) { assert.strictEqual(2, res.length); - assert.strictEqual("table", res[0]); - assert.strictEqual("OK", res[1]); + assert.strictEqual('table', res[0]); + assert.strictEqual('OK', res[1]); return done(err); }); }); it('returns an appropriate representation of a Lua error reply', function (done) { - client.set("error reply key", "error reply value", function (err, res) { + client.set('error reply key', 'error reply value', function (err, res) { if (err) return done(err); client.eval("local foo = redis.pcall('incr','error reply key'); return {type(foo),foo['err']}", 0, function (err, res) { assert.strictEqual(2, res.length); - assert.strictEqual("table", res[0]); - assert.strictEqual("ERR value is not an integer or out of range", res[1]); + assert.strictEqual('table', res[0]); + assert.strictEqual('ERR value is not an integer or out of range', res[1]); return done(err); }); }); }); it('returns an appropriate representation of a Lua nil reply', function (done) { - client.del("nil reply key", function (err, res) { + client.del('nil reply key', function (err, res) { if (err) return done(err); client.eval("local foo = redis.call('get','nil reply key'); return {type(foo),foo == false}", 0, function (err, res) { if (err) throw err; assert.strictEqual(2, res.length); - assert.strictEqual("boolean", res[0]); + assert.strictEqual('boolean', res[0]); assert.strictEqual(1, res[1]); return done(err); }); diff --git a/test/commands/exists.spec.js b/test/commands/exists.spec.js index 7135c10553..01a1b6891d 100644 --- a/test/commands/exists.spec.js +++ b/test/commands/exists.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'exists' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/expire.spec.js b/test/commands/expire.spec.js index 679b152f5a..4994caf86f 100644 --- a/test/commands/expire.spec.js +++ b/test/commands/expire.spec.js @@ -1,36 +1,36 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'expire' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('expires key after timeout', function (done) { - client.set(['expiry key', 'bar'], helper.isString("OK")); - client.EXPIRE("expiry key", "1", helper.isNumber(1)); + client.set(['expiry key', 'bar'], helper.isString('OK')); + client.EXPIRE('expiry key', '1', helper.isNumber(1)); setTimeout(function () { - client.exists(["expiry key"], helper.isNumber(0, done)); + client.exists(['expiry key'], helper.isNumber(0, done)); }, 1100); }); it('expires key after timeout with array syntax', function (done) { - client.set(['expiry key', 'bar'], helper.isString("OK")); - client.EXPIRE(["expiry key", "1"], helper.isNumber(1)); + client.set(['expiry key', 'bar'], helper.isString('OK')); + client.EXPIRE(['expiry key', '1'], helper.isNumber(1)); setTimeout(function () { - client.exists(["expiry key"], helper.isNumber(0, done)); + client.exists(['expiry key'], helper.isNumber(0, done)); }, 1100); }); diff --git a/test/commands/flushdb.spec.js b/test/commands/flushdb.spec.js index 97e46e36e1..b96c4b1031 100644 --- a/test/commands/flushdb.spec.js +++ b/test/commands/flushdb.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; var uuid = require('uuid'); describe("The 'flushdb' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, key2; beforeEach(function () { @@ -18,18 +18,18 @@ describe("The 'flushdb' method", function () { key2 = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.flushdb(function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -37,12 +37,12 @@ describe("The 'flushdb' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { done(); }); }); @@ -51,7 +51,7 @@ describe("The 'flushdb' method", function () { client.end(true); }); - describe("when there is data in Redis", function () { + describe('when there is data in Redis', function () { beforeEach(function (done) { client.mset(key, uuid.v4(), key2, uuid.v4(), helper.isNotError()); @@ -62,38 +62,38 @@ describe("The 'flushdb' method", function () { }); }); - it("deletes all the keys", function (done) { - client.flushdb(function(err, res) { + it('deletes all the keys', function (done) { + client.flushdb(function (err, res) { assert.equal(res, 'OK'); client.mget(key, key2, function (err, res) { - assert.strictEqual(null, err, "Unexpected error returned"); - assert.strictEqual(true, Array.isArray(res), "Results object should be an array."); - assert.strictEqual(2, res.length, "Results array should have length 2."); - assert.strictEqual(null, res[0], "Redis key should have been flushed."); - assert.strictEqual(null, res[1], "Redis key should have been flushed."); + assert.strictEqual(null, err, 'Unexpected error returned'); + assert.strictEqual(true, Array.isArray(res), 'Results object should be an array.'); + assert.strictEqual(2, res.length, 'Results array should have length 2.'); + assert.strictEqual(null, res[0], 'Redis key should have been flushed.'); + assert.strictEqual(null, res[1], 'Redis key should have been flushed.'); done(err); }); }); }); - it("results in a db size of zero", function (done) { - client.flushdb(function(err, res) { + it('results in a db size of zero', function (done) { + client.flushdb(function (err, res) { client.dbsize([], function (err, res) { helper.isNotError()(err, res); helper.isType.number()(err, res); - assert.strictEqual(0, res, "Flushing db should result in db size 0"); + assert.strictEqual(0, res, 'Flushing db should result in db size 0'); done(); }); }); }); - it("results in a db size of zero without a callback", function (done) { + it('results in a db size of zero without a callback', function (done) { client.flushdb(); - setTimeout(function(err, res) { + setTimeout(function (err, res) { client.dbsize([], function (err, res) { helper.isNotError()(err, res); helper.isType.number()(err, res); - assert.strictEqual(0, res, "Flushing db should result in db size 0"); + assert.strictEqual(0, res, 'Flushing db should result in db size 0'); done(); }); }, 25); diff --git a/test/commands/geoadd.spec.js b/test/commands/geoadd.spec.js index 026d0fe717..3614910322 100644 --- a/test/commands/geoadd.spec.js +++ b/test/commands/geoadd.spec.js @@ -1,26 +1,26 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'geoadd' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('returns 1 if the key exists', function (done) { helper.serverVersionAtLeast.call(this, client, [3, 2, 0]); - client.geoadd("mycity:21:0:location", "13.361389","38.115556","COR", function(err, res) { + 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(); diff --git a/test/commands/get.spec.js b/test/commands/get.spec.js index cc4a7386a1..dc4b92da25 100644 --- a/test/commands/get.spec.js +++ b/test/commands/get.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +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) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, value; beforeEach(function () { @@ -18,37 +18,37 @@ describe("The 'get' method", function () { value = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (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 () { + 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 () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { done(); }); }); @@ -57,7 +57,7 @@ describe("The 'get' method", function () { client.end(true); }); - describe("when the key exists in Redis", function () { + describe('when the key exists in Redis', function () { beforeEach(function (done) { client.set(key, value, function (err, res) { helper.isNotError()(err, res); @@ -65,7 +65,7 @@ describe("The 'get' method", function () { }); }); - it("gets the value correctly", function (done) { + it('gets the value correctly', function (done) { client.GET(key, function (err, res) { helper.isString(value)(err, res); done(err); @@ -74,15 +74,15 @@ describe("The 'get' method", function () { 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) { + client.on('error', function (err) { throw err; }); setTimeout(done, 50); }); }); - describe("when the key does not exist in Redis", function () { - it("gets a null value", function (done) { + 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); diff --git a/test/commands/getset.spec.js b/test/commands/getset.spec.js index 0ebbb12f15..ea6b5d5ef7 100644 --- a/test/commands/getset.spec.js +++ b/test/commands/getset.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; var uuid = require('uuid'); describe("The 'getset' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, value, value2; beforeEach(function () { @@ -19,18 +19,18 @@ describe("The 'getset' method", function () { value2 = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.get(key, function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -38,12 +38,12 @@ describe("The 'getset' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { done(); }); }); @@ -52,7 +52,7 @@ describe("The 'getset' method", function () { client.end(true); }); - describe("when the key exists in Redis", function () { + describe('when the key exists in Redis', function () { beforeEach(function (done) { client.set(key, value, function (err, res) { helper.isNotError()(err, res); @@ -60,7 +60,7 @@ describe("The 'getset' method", function () { }); }); - it("gets the value correctly", function (done) { + it('gets the value correctly', function (done) { client.GETSET(key, value2, function (err, res) { helper.isString(value)(err, res); client.get(key, function (err, res) { @@ -70,7 +70,7 @@ describe("The 'getset' method", function () { }); }); - it("gets the value correctly with array syntax", function (done) { + it('gets the value correctly with array syntax', function (done) { client.GETSET([key, value2], function (err, res) { helper.isString(value)(err, res); client.get(key, function (err, res) { @@ -80,7 +80,7 @@ describe("The 'getset' method", function () { }); }); - it("gets the value correctly with array syntax style 2", function (done) { + it('gets the value correctly with array syntax style 2', function (done) { client.GETSET(key, [value2], function (err, res) { helper.isString(value)(err, res); client.get(key, function (err, res) { @@ -91,8 +91,8 @@ describe("The 'getset' method", function () { }); }); - describe("when the key does not exist in Redis", function () { - it("gets a null value", function (done) { + describe('when the key does not exist in Redis', function () { + it('gets a null value', function (done) { client.getset(key, value, function (err, res) { helper.isNull()(err, res); done(err); diff --git a/test/commands/hgetall.spec.js b/test/commands/hgetall.spec.js index e681379808..d345b13c92 100644 --- a/test/commands/hgetall.spec.js +++ b/test/commands/hgetall.spec.js @@ -1,48 +1,48 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hgetall' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; describe('regular client', function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('handles simple keys and values', function (done) { - client.hmset(["hosts", "mjr", "1", "another", "23", "home", "1234"], helper.isString("OK")); - client.HGETALL(["hosts"], function (err, obj) { + client.hmset(['hosts', 'mjr', '1', 'another', '23', 'home', '1234'], helper.isString('OK')); + client.HGETALL(['hosts'], function (err, obj) { assert.strictEqual(3, Object.keys(obj).length); - assert.strictEqual("1", obj.mjr.toString()); - assert.strictEqual("23", obj.another.toString()); - assert.strictEqual("1234", obj.home.toString()); + assert.strictEqual('1', obj.mjr.toString()); + assert.strictEqual('23', obj.another.toString()); + assert.strictEqual('1234', obj.home.toString()); return done(err); }); }); it('handles fetching keys set using an object', function (done) { - client.HMSET("msg_test", { message: "hello" }, helper.isString("OK")); - client.hgetall("msg_test", function (err, obj) { + client.HMSET('msg_test', { message: 'hello' }, helper.isString('OK')); + client.hgetall('msg_test', function (err, obj) { assert.strictEqual(1, Object.keys(obj).length); - assert.strictEqual(obj.message, "hello"); + assert.strictEqual(obj.message, 'hello'); return done(err); }); }); it('handles fetching a messing key', function (done) { - client.hgetall("missing", function (err, obj) { + client.hgetall('missing', function (err, obj) { assert.strictEqual(null, obj); return done(err); }); @@ -57,18 +57,18 @@ describe("The 'hgetall' method", function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('returns binary results', function (done) { - client.hmset(["bhosts", "mjr", "1", "another", "23", "home", "1234", new Buffer([0xAA, 0xBB, 0x00, 0xF0]), new Buffer([0xCC, 0xDD, 0x00, 0xF0])], helper.isString("OK")); - client.HGETALL("bhosts", function (err, obj) { + client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', new Buffer([0xAA, 0xBB, 0x00, 0xF0]), new Buffer([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK')); + client.HGETALL('bhosts', function (err, obj) { assert.strictEqual(4, Object.keys(obj).length); - assert.strictEqual("1", obj.mjr.toString()); - assert.strictEqual("23", obj.another.toString()); - assert.strictEqual("1234", obj.home.toString()); + assert.strictEqual('1', obj.mjr.toString()); + assert.strictEqual('23', obj.another.toString()); + assert.strictEqual('1234', obj.home.toString()); assert.strictEqual((new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary'), Object.keys(obj)[3]); assert.strictEqual((new Buffer([0xCC, 0xDD, 0x00, 0xF0])).toString('binary'), obj[(new Buffer([0xAA, 0xBB, 0x00, 0xF0])).toString('binary')].toString('binary')); return done(err); diff --git a/test/commands/hincrby.spec.js b/test/commands/hincrby.spec.js index 5e933d23ce..e94232d9a0 100644 --- a/test/commands/hincrby.spec.js +++ b/test/commands/hincrby.spec.js @@ -1,33 +1,33 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hincrby' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; - var hash = "test hash"; + var hash = 'test hash'; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('increments a key that has already been set', function (done) { - var field = "field 1"; + var field = 'field 1'; client.HSET(hash, field, 33); client.hincrby(hash, field, 10, helper.isNumber(43, done)); }); it('increments a key that has not been set', function (done) { - var field = "field 2"; + var field = 'field 2'; client.HINCRBY(hash, field, 10, helper.isNumber(10, done)); }); diff --git a/test/commands/hlen.spec.js b/test/commands/hlen.spec.js index b8fa3e99c6..5dcab6ce8e 100644 --- a/test/commands/hlen.spec.js +++ b/test/commands/hlen.spec.js @@ -1,27 +1,27 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hlen' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('reports the count of keys', function (done) { - var hash = "test hash"; - var field1 = new Buffer("0123456789"); - var value1 = new Buffer("abcdefghij"); + var hash = 'test hash'; + var field1 = new Buffer('0123456789'); + var value1 = new Buffer('abcdefghij'); var field2 = new Buffer(0); var value2 = new Buffer(0); diff --git a/test/commands/hmget.spec.js b/test/commands/hmget.spec.js index 996ed25570..09bb89f258 100644 --- a/test/commands/hmget.spec.js +++ b/test/commands/hmget.spec.js @@ -1,62 +1,62 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hmget' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var hash = 'test hash'; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("error", done); - client.once("ready", function () { + client.once('error', done); + client.once('ready', function () { client.flushdb(); - client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}, helper.isString('OK', done)); + client.HMSET(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'}, helper.isString('OK', done)); }); }); it('allows keys to be specified using multiple arguments', function (done) { - client.hmget(hash, "0123456789", "some manner of key", function (err, reply) { - assert.strictEqual("abcdefghij", reply[0].toString()); - assert.strictEqual("a type of value", reply[1].toString()); + client.hmget(hash, '0123456789', 'some manner of key', function (err, reply) { + assert.strictEqual('abcdefghij', reply[0].toString()); + assert.strictEqual('a type of value', reply[1].toString()); return done(err); }); }); it('allows keys to be specified by passing an array without manipulating the array', function (done) { - var data = ["0123456789", "some manner of key"]; + var data = ['0123456789', 'some manner of key']; client.HMGET(hash, data, function (err, reply) { assert.strictEqual(data.length, 2); - assert.strictEqual("abcdefghij", reply[0].toString()); - assert.strictEqual("a type of value", reply[1].toString()); + assert.strictEqual('abcdefghij', reply[0].toString()); + assert.strictEqual('a type of value', reply[1].toString()); return done(err); }); }); it('allows keys to be specified by passing an array as first argument', function (done) { - client.HMGET([hash, "0123456789", "some manner of key"], function (err, reply) { - assert.strictEqual("abcdefghij", reply[0].toString()); - assert.strictEqual("a type of value", reply[1].toString()); + client.HMGET([hash, '0123456789', 'some manner of key'], function (err, reply) { + assert.strictEqual('abcdefghij', reply[0].toString()); + assert.strictEqual('a type of value', reply[1].toString()); return done(err); }); }); it('allows a single key to be specified in an array', function (done) { - client.HMGET(hash, ["0123456789"], function (err, reply) { - assert.strictEqual("abcdefghij", reply[0].toString()); + client.HMGET(hash, ['0123456789'], function (err, reply) { + assert.strictEqual('abcdefghij', reply[0].toString()); return done(err); }); }); it('allows keys to be specified that have not yet been set', function (done) { - client.HMGET(hash, "missing thing", "another missing thing", function (err, reply) { + client.HMGET(hash, 'missing thing', 'another missing thing', function (err, reply) { assert.strictEqual(null, reply[0]); assert.strictEqual(null, reply[1]); return done(err); diff --git a/test/commands/hmset.spec.js b/test/commands/hmset.spec.js index e6f9931236..c96b7c5b67 100644 --- a/test/commands/hmset.spec.js +++ b/test/commands/hmset.spec.js @@ -1,27 +1,27 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hmset' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var hash = 'test hash'; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('handles redis-style syntax', function (done) { - client.HMSET(hash, "0123456789", "abcdefghij", "some manner of key", "a type of value", "otherTypes", 555, helper.isString('OK')); + client.HMSET(hash, '0123456789', 'abcdefghij', 'some manner of key', 'a type of value', 'otherTypes', 555, helper.isString('OK')); client.HGETALL(hash, function (err, obj) { assert.equal(obj['0123456789'], 'abcdefghij'); assert.equal(obj['some manner of key'], 'a type of value'); @@ -30,7 +30,7 @@ describe("The 'hmset' method", function () { }); it('handles object-style syntax', function (done) { - client.hmset(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK')); + client.hmset(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}, helper.isString('OK')); client.HGETALL(hash, function (err, obj) { assert.equal(obj['0123456789'], 'abcdefghij'); assert.equal(obj['some manner of key'], 'a type of value'); @@ -39,7 +39,7 @@ describe("The 'hmset' method", function () { }); it('handles object-style syntax and the key being a number', function (done) { - client.HMSET(231232, {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}, helper.isString('OK')); + client.HMSET(231232, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}, helper.isString('OK')); client.HGETALL(231232, function (err, obj) { assert.equal(obj['0123456789'], 'abcdefghij'); assert.equal(obj['some manner of key'], 'a type of value'); @@ -101,7 +101,7 @@ describe("The 'hmset' method", function () { }); it('handles object-style syntax without callback', function (done) { - client.HMSET(hash, {"0123456789": "abcdefghij", "some manner of key": "a type of value"}); + client.HMSET(hash, {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value'}); client.HGETALL(hash, function (err, obj) { assert.equal(obj['0123456789'], 'abcdefghij'); assert.equal(obj['some manner of key'], 'a type of value'); diff --git a/test/commands/hset.spec.js b/test/commands/hset.spec.js index d87f4d04ce..d0ce7f5481 100644 --- a/test/commands/hset.spec.js +++ b/test/commands/hset.spec.js @@ -1,39 +1,39 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'hset' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var hash = 'test hash'; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('allows a value to be set in a hash', function (done) { - var field = new Buffer("0123456789"); - var value = new Buffer("abcdefghij"); + var field = new Buffer('0123456789'); + var value = new Buffer('abcdefghij'); client.hset(hash, field, value, helper.isNumber(1)); client.HGET(hash, field, helper.isString(value.toString(), done)); }); it('handles an empty value', function (done) { - var field = new Buffer("0123456789"); + var field = new Buffer('0123456789'); var value = new Buffer(0); client.HSET(hash, field, value, helper.isNumber(1)); - client.HGET([hash, field], helper.isString("", done)); + client.HGET([hash, field], helper.isString('', done)); }); it('handles empty key and value', function (done) { @@ -46,11 +46,11 @@ describe("The 'hset' method", function () { }); it('warns if someone passed a array either as field or as value', function (done) { - var hash = "test hash"; - var field = "array"; + var hash = 'test hash'; + var field = 'array'; // This would be converted to "array contents" but if you use more than one entry, // it'll result in e.g. "array contents,second content" and this is not supported and considered harmful - var value = ["array contents"]; + var value = ['array contents']; client.on('warning', function (msg) { assert.strictEqual( msg, @@ -64,23 +64,23 @@ describe("The 'hset' method", function () { }); it('does not error when a buffer and date are set as values on the same hash', function (done) { - var hash = "test hash"; - var field1 = "buffer"; - var value1 = new Buffer("abcdefghij"); - var field2 = "date"; + var hash = 'test hash'; + var field1 = 'buffer'; + var value1 = new Buffer('abcdefghij'); + var field2 = 'date'; var value2 = new Date(); - client.HMSET(hash, field1, value1, field2, value2, helper.isString("OK", done)); + client.HMSET(hash, field1, value1, field2, value2, helper.isString('OK', done)); }); it('does not error when a buffer and date are set as fields on the same hash', function (done) { - var hash = "test hash"; - var value1 = "buffer"; - var field1 = new Buffer("abcdefghij"); - var value2 = "date"; + var hash = 'test hash'; + var value1 = 'buffer'; + var field1 = new Buffer('abcdefghij'); + var value2 = 'date'; var field2 = new Date(); - client.HMSET(hash, field1, value1, field2, value2, helper.isString("OK", done)); + client.HMSET(hash, field1, value1, field2, value2, helper.isString('OK', done)); }); afterEach(function () { diff --git a/test/commands/incr.spec.js b/test/commands/incr.spec.js index b0d605ae22..ab385ecbbf 100644 --- a/test/commands/incr.spec.js +++ b/test/commands/incr.spec.js @@ -1,24 +1,24 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; describe("The 'incr' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { - var key = "sequence"; + describe('using ' + parser + ' and ' + ip, function () { + var key = 'sequence'; - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { - client.set(key, "9007199254740992", function (err, res) { + client.once('ready', function () { + client.set(key, '9007199254740992', function (err, res) { helper.isNotError()(err, res); client.quit(); }); @@ -30,7 +30,7 @@ describe("The 'incr' method", function () { client.end(true); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.incr(function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -38,7 +38,7 @@ describe("The 'incr' method", function () { }); }); - describe("when connected and a value in Redis", function () { + describe('when connected and a value in Redis', function () { var client; before(function (done) { @@ -51,9 +51,9 @@ describe("The 'incr' method", function () { 9007199254740997 -> 9007199254740996 */ client = redis.createClient.apply(null, args); - client.once("error", done); - client.once("ready", function () { - client.set(key, "9007199254740992", function (err, res) { + client.once('error', done); + client.once('ready', function () { + client.set(key, '9007199254740992', function (err, res) { helper.isNotError()(err, res); done(); }); @@ -64,41 +64,41 @@ describe("The 'incr' method", function () { client.end(true); }); - it("changes the last digit from 2 to 3", function (done) { + it('changes the last digit from 2 to 3', function (done) { client.INCR(key, function (err, res) { - helper.isString("9007199254740993")(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) { + 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); + helper.isString('9007199254740994')(err, res); done(err); }); }); - describe("and again", function () { - it("changes the last digit from 4 to 5", function (done) { + 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); + helper.isString('9007199254740995')(err, res); done(err); }); }); - describe("and again", function () { - it("changes the last digit from 5 to 6", function (done) { + 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); + helper.isString('9007199254740996')(err, res); done(err); }); }); - describe("and again", function () { - it("changes the last digit from 6 to 7", function (done) { + 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); + helper.isString('9007199254740997')(err, res); done(err); }); }); diff --git a/test/commands/info.spec.js b/test/commands/info.spec.js index ca4ec70080..e0a01457ec 100644 --- a/test/commands/info.spec.js +++ b/test/commands/info.spec.js @@ -1,20 +1,20 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; describe("The 'info' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushall(done); }); }); @@ -23,7 +23,7 @@ describe("The 'info' method", function () { client.end(true); }); - it("update server_info after a info command", function (done) { + it('update server_info after a info command', function (done) { client.set('foo', 'bar'); client.info(); client.select(2, function () { @@ -37,7 +37,7 @@ describe("The 'info' method", function () { }, 150); }); - it("works with optional section provided with and without callback", function (done) { + it('works with optional section provided with and without callback', function (done) { client.set('foo', 'bar'); client.info('keyspace'); client.select(2, function () { @@ -65,7 +65,7 @@ describe("The 'info' method", function () { client.info(function () {}); }); - it("emit error after a failure", function (done) { + it('emit error after a failure', function (done) { client.info(); client.once('error', function (err) { assert.strictEqual(err.code, 'UNCERTAIN_STATE'); diff --git a/test/commands/keys.spec.js b/test/commands/keys.spec.js index 7af3ae40c9..1aff0cea14 100644 --- a/test/commands/keys.spec.js +++ b/test/commands/keys.spec.js @@ -1,31 +1,31 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var crypto = require("crypto"); -var helper = require("../helper"); +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 () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushall(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) { + 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")); + assert.ok(~results.indexOf('test keys 1')); + assert.ok(~results.indexOf('test keys 2')); return done(err); }); }); @@ -35,18 +35,18 @@ describe("The 'keys' method", function () { 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 + '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) { + client.mset(keys_values.reduce(function (a, b) { return a.concat(b); - }), helper.isString("OK")); + }), helper.isString('OK')); - client.keys("multibulk:*", function(err, results) { - assert.deepEqual(keys_values.map(function(val) { + client.keys('multibulk:*', function (err, results) { + assert.deepEqual(keys_values.map(function (val) { return val[0]; }).sort(), results.sort()); return done(err); diff --git a/test/commands/mget.spec.js b/test/commands/mget.spec.js index 8e395dedbe..83d69f837f 100644 --- a/test/commands/mget.spec.js +++ b/test/commands/mget.spec.js @@ -1,64 +1,64 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'mget' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("error", done); - client.once("ready", function () { + client.once('error', done); + client.once('ready', function () { client.flushdb(); - client.mset(["mget keys 1", "mget val 1", "mget keys 2", "mget val 2", "mget keys 3", "mget val 3"], done); + client.mset(['mget keys 1', 'mget val 1', 'mget keys 2', 'mget val 2', 'mget keys 3', 'mget val 3'], done); }); }); it('handles fetching multiple keys in argument form', function (done) { - client.mset(["mget keys 1", "mget val 1", "mget keys 2", "mget val 2", "mget keys 3", "mget val 3"], helper.isString("OK")); - client.MGET("mget keys 1", "mget keys 2", "mget keys 3", function (err, results) { + client.mset(['mget keys 1', 'mget val 1', 'mget keys 2', 'mget val 2', 'mget keys 3', 'mget val 3'], helper.isString('OK')); + client.MGET('mget keys 1', 'mget keys 2', 'mget keys 3', function (err, results) { assert.strictEqual(3, results.length); - assert.strictEqual("mget val 1", results[0].toString()); - assert.strictEqual("mget val 2", results[1].toString()); - assert.strictEqual("mget val 3", results[2].toString()); + assert.strictEqual('mget val 1', results[0].toString()); + assert.strictEqual('mget val 2', results[1].toString()); + assert.strictEqual('mget val 3', results[2].toString()); return done(err); }); }); it('handles fetching multiple keys via an array', function (done) { - client.mget(["mget keys 1", "mget keys 2", "mget keys 3"], function (err, results) { - assert.strictEqual("mget val 1", results[0].toString()); - assert.strictEqual("mget val 2", results[1].toString()); - assert.strictEqual("mget val 3", results[2].toString()); + client.mget(['mget keys 1', 'mget keys 2', 'mget keys 3'], function (err, results) { + assert.strictEqual('mget val 1', results[0].toString()); + assert.strictEqual('mget val 2', results[1].toString()); + assert.strictEqual('mget val 3', results[2].toString()); return done(err); }); }); it('handles fetching multiple keys, when some keys do not exist', function (done) { - client.MGET("mget keys 1", ["some random shit", "mget keys 2", "mget keys 3"], function (err, results) { + client.MGET('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3'], function (err, results) { assert.strictEqual(4, results.length); - assert.strictEqual("mget val 1", results[0].toString()); + assert.strictEqual('mget val 1', results[0].toString()); assert.strictEqual(null, results[1]); - assert.strictEqual("mget val 2", results[2].toString()); - assert.strictEqual("mget val 3", results[3].toString()); + assert.strictEqual('mget val 2', results[2].toString()); + assert.strictEqual('mget val 3', results[3].toString()); return done(err); }); }); it('handles fetching multiple keys, when some keys do not exist promisified', function () { - return client.MGETAsync("mget keys 1", ["some random shit", "mget keys 2", "mget keys 3"]).then(function (results) { + return client.MGETAsync('mget keys 1', ['some random shit', 'mget keys 2', 'mget keys 3']).then(function (results) { assert.strictEqual(4, results.length); - assert.strictEqual("mget val 1", results[0].toString()); + assert.strictEqual('mget val 1', results[0].toString()); assert.strictEqual(null, results[1]); - assert.strictEqual("mget val 2", results[2].toString()); - assert.strictEqual("mget val 3", results[3].toString()); + assert.strictEqual('mget val 2', results[2].toString()); + assert.strictEqual('mget val 3', results[3].toString()); }); }); diff --git a/test/commands/mset.spec.js b/test/commands/mset.spec.js index 81ab6d3bc6..c6963641a2 100644 --- a/test/commands/mset.spec.js +++ b/test/commands/mset.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; var uuid = require('uuid'); describe("The 'mset' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, value, key2, value2; beforeEach(function () { @@ -20,18 +20,18 @@ describe("The 'mset' method", function () { value2 = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.mset(key, value, key2, value2, function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -39,12 +39,12 @@ describe("The 'mset' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { done(); }); }); @@ -53,10 +53,10 @@ describe("The 'mset' method", function () { client.end(true); }); - describe("and a callback is specified", function () { - describe("with valid parameters", function () { - it("sets the value correctly", function (done) { - client.mset(key, value, key2, value2, function(err) { + describe('and a callback is specified', function () { + describe('with valid parameters', function () { + it('sets the value correctly', function (done) { + client.mset(key, value, key2, value2, function (err) { if (err) { return done(err); } @@ -67,7 +67,7 @@ describe("The 'mset' method", function () { }); describe("with undefined 'key' parameter and missing 'value' parameter", function () { - it("reports an error", function (done) { + it('reports an error', function (done) { client.mset(undefined, function (err, res) { helper.isError()(err, null); done(); @@ -77,15 +77,15 @@ describe("The 'mset' method", function () { }); - describe("and no callback is specified", function () { - describe("with valid parameters", function () { - it("sets the value correctly", function (done) { + describe('and no callback is specified', function () { + describe('with valid parameters', function () { + it('sets the value correctly', function (done) { client.mset(key, value2, key2, value); client.get(key, helper.isString(value2)); client.get(key2, helper.isString(value, done)); }); - it("sets the value correctly with array syntax", function (done) { + it('sets the value correctly with array syntax', function (done) { client.mset([key, value2, key2, value]); client.get(key, helper.isString(value2)); client.get(key2, helper.isString(value, done)); @@ -94,7 +94,7 @@ describe("The 'mset' method", function () { describe("with undefined 'key' and missing 'value' parameter", function () { // this behavior is different from the 'set' behavior. - it("emits an error", function (done) { + it('emits an error', function (done) { client.on('error', function (err) { assert.equal(err.message, "ERR wrong number of arguments for 'mset' command"); done(); diff --git a/test/commands/msetnx.spec.js b/test/commands/msetnx.spec.js index 59cd62187c..a2f2ab1724 100644 --- a/test/commands/msetnx.spec.js +++ b/test/commands/msetnx.spec.js @@ -1,33 +1,33 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'msetnx' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('if any keys exist entire operation fails', function (done) { - client.mset(["mset1", "val1", "mset2", "val2", "mset3", "val3"], helper.isString("OK")); - client.MSETNX(["mset3", "val3", "mset4", "val4"], helper.isNumber(0)); - client.exists(["mset4"], helper.isNumber(0, done)); + client.mset(['mset1', 'val1', 'mset2', 'val2', 'mset3', 'val3'], helper.isString('OK')); + client.MSETNX(['mset3', 'val3', 'mset4', 'val4'], helper.isNumber(0)); + client.exists(['mset4'], helper.isNumber(0, done)); }); it('sets multiple keys if all keys are not set', function (done) { - client.msetnx(["mset3", "val3", "mset4", "val4"], helper.isNumber(1)); - client.exists(["mset3"], helper.isNumber(1)); - client.exists(["mset3"], helper.isNumber(1, done)); + client.msetnx(['mset3', 'val3', 'mset4', 'val4'], helper.isNumber(1)); + client.exists(['mset3'], helper.isNumber(1)); + client.exists(['mset3'], helper.isNumber(1, done)); }); afterEach(function () { diff --git a/test/commands/randomkey.test.js b/test/commands/randomkey.test.js index 671942effe..cf453e12e4 100644 --- a/test/commands/randomkey.test.js +++ b/test/commands/randomkey.test.js @@ -1,26 +1,26 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'randomkey' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('returns a random key', function (done) { - client.mset(["test keys 1", "test val 1", "test keys 2", "test val 2"], helper.isString('OK')); + client.mset(['test keys 1', 'test val 1', 'test keys 2', 'test val 2'], helper.isString('OK')); client.RANDOMKEY([], function (err, results) { assert.strictEqual(true, /test keys.+/.test(results)); return done(err); diff --git a/test/commands/rename.spec.js b/test/commands/rename.spec.js index e6d8b938a1..cb3d7c3168 100644 --- a/test/commands/rename.spec.js +++ b/test/commands/rename.spec.js @@ -1,33 +1,33 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'rename' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('populates the new key', function (done) { - client.set(['foo', 'bar'], helper.isString("OK")); - client.rename(["foo", "new foo"], helper.isString("OK")); - client.exists(["new foo"], helper.isNumber(1, done)); + client.set(['foo', 'bar'], helper.isString('OK')); + client.rename(['foo', 'new foo'], helper.isString('OK')); + client.exists(['new foo'], helper.isNumber(1, done)); }); it('removes the old key', function (done) { - client.set(['foo', 'bar'], helper.isString("OK")); - client.RENAME(["foo", "new foo"], helper.isString("OK")); - client.exists(["foo"], helper.isNumber(0, done)); + client.set(['foo', 'bar'], helper.isString('OK')); + client.RENAME(['foo', 'new foo'], helper.isString('OK')); + client.exists(['foo'], helper.isNumber(0, done)); }); afterEach(function () { diff --git a/test/commands/renamenx.spec.js b/test/commands/renamenx.spec.js index ef503c96fb..3da640a0d8 100644 --- a/test/commands/renamenx.spec.js +++ b/test/commands/renamenx.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'renamenx' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/rpush.spec.js b/test/commands/rpush.spec.js index 59d776cbcc..d137dc6473 100644 --- a/test/commands/rpush.spec.js +++ b/test/commands/rpush.spec.js @@ -1,27 +1,27 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; var assert = require('assert'); describe("The 'rpush' command", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('inserts multiple values at a time into a list', function (done) { client.rpush('test', ['list key', 'should be a list']); - client.lrange('test', 0, -1, function(err, res) { + client.lrange('test', 0, -1, function (err, res) { assert.equal(res[0], 'list key'); assert.equal(res[1], 'should be a list'); done(err); diff --git a/test/commands/sadd.spec.js b/test/commands/sadd.spec.js index 6333d940ff..c2316739b7 100644 --- a/test/commands/sadd.spec.js +++ b/test/commands/sadd.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sadd' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -33,23 +33,23 @@ describe("The 'sadd' method", function () { }); it('allows multiple values to be added to the set', function (done) { - client.sadd("set0", ["member0", "member1", "member2"], helper.isNumber(3)); - client.smembers("set0", function (err, res) { + client.sadd('set0', ['member0', 'member1', 'member2'], helper.isNumber(3)); + client.smembers('set0', function (err, res) { assert.strictEqual(res.length, 3); - assert.ok(~res.indexOf("member0")); - assert.ok(~res.indexOf("member1")); - assert.ok(~res.indexOf("member2")); + assert.ok(~res.indexOf('member0')); + assert.ok(~res.indexOf('member1')); + assert.ok(~res.indexOf('member2')); return done(err); }); }); it('allows multiple values to be added to the set with a different syntax', function (done) { - client.sadd(["set0", "member0", "member1", "member2"], helper.isNumber(3)); - client.smembers("set0", function (err, res) { + client.sadd(['set0', 'member0', 'member1', 'member2'], helper.isNumber(3)); + client.smembers('set0', function (err, res) { assert.strictEqual(res.length, 3); - assert.ok(~res.indexOf("member0")); - assert.ok(~res.indexOf("member1")); - assert.ok(~res.indexOf("member2")); + assert.ok(~res.indexOf('member0')); + assert.ok(~res.indexOf('member1')); + assert.ok(~res.indexOf('member2')); return done(err); }); }); diff --git a/test/commands/scard.spec.js b/test/commands/scard.spec.js index 162513b4ed..5cf9b4eb73 100644 --- a/test/commands/scard.spec.js +++ b/test/commands/scard.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'scard' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/script.spec.js b/test/commands/script.spec.js index e69f25025e..25a44930b5 100644 --- a/test/commands/script.spec.js +++ b/test/commands/script.spec.js @@ -1,23 +1,23 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var crypto = require("crypto"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var crypto = require('crypto'); +var helper = require('../helper'); var redis = config.redis; describe("The 'script' method", function () { - helper.allTests(function(parser, ip, args) { - var command = "return 99"; + helper.allTests(function (parser, ip, args) { + var command = 'return 99'; var commandSha = crypto.createHash('sha1').update(command).digest('hex'); - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -27,7 +27,7 @@ describe("The 'script' method", function () { }); it("loads script with client.script('load')", function (done) { - client.script("load", command, function(err, result) { + client.script('load', command, function (err, result) { assert.strictEqual(result, commandSha); return done(); }); @@ -38,14 +38,14 @@ describe("The 'script' method", function () { }); it('allows a script to be loaded as part of a chained transaction', function (done) { - client.multi().script("load", command).exec(function(err, result) { + client.multi().script('load', command).exec(function (err, result) { assert.strictEqual(result[0], commandSha); return done(); }); }); it("allows a script to be loaded using a transaction's array syntax", function (done) { - client.multi([['script', 'load', command]]).exec(function(err, result) { + client.multi([['script', 'load', command]]).exec(function (err, result) { assert.strictEqual(result[0], commandSha); return done(); }); diff --git a/test/commands/sdiff.spec.js b/test/commands/sdiff.spec.js index 4a9e8c651b..e3963ecdf0 100644 --- a/test/commands/sdiff.spec.js +++ b/test/commands/sdiff.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sdiff' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/sdiffstore.spec.js b/test/commands/sdiffstore.spec.js index eb8fb79952..1797ca9e43 100644 --- a/test/commands/sdiffstore.spec.js +++ b/test/commands/sdiffstore.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sdiffstore' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/select.spec.js b/test/commands/select.spec.js index 2d0ac3a104..4e418767fb 100644 --- a/test/commands/select.spec.js +++ b/test/commands/select.spec.js @@ -1,27 +1,27 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; describe("The 'select' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { - describe("when not connected", function () { + describe('using ' + parser + ' and ' + ip, function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("returns an error if redis is not connected", function (done) { + it('returns an error if redis is not connected', function (done) { var buffering = client.select(1, function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -30,12 +30,12 @@ describe("The 'select' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -44,32 +44,32 @@ describe("The 'select' method", function () { client.end(true); }); - it("changes the database and calls the callback", function (done) { + it('changes the database and calls the callback', function (done) { // default value of null means database 0 will be used. - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); var buffering = client.SELECT(1, function (err, res) { helper.isNotError()(err, res); - assert.strictEqual(client.selected_db, 1, "db should be 1 after select"); + assert.strictEqual(client.selected_db, 1, 'db should be 1 after select'); done(); }); assert(typeof buffering === 'boolean'); }); - describe("and a callback is specified", function () { - describe("with a valid db index", function () { - it("selects the appropriate database", function (done) { - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + describe('and a callback is specified', function () { + describe('with a valid db index', function () { + it('selects the appropriate database', function (done) { + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); client.select(1, function (err) { assert.equal(err, null); - assert.equal(client.selected_db, 1, "we should have selected the new valid DB"); + assert.equal(client.selected_db, 1, 'we should have selected the new valid DB'); return done(); }); }); }); - describe("with an invalid db index", function () { - it("returns an error", function (done) { - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + describe('with an invalid db index', function () { + it('returns an error', function (done) { + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); client.select(9999, function (err) { assert.equal(err.code, 'ERR'); assert.equal(err.message, 'ERR invalid DB index'); @@ -79,21 +79,21 @@ describe("The 'select' method", function () { }); }); - describe("and no callback is specified", function () { - describe("with a valid db index", function () { - it("selects the appropriate database", function (done) { - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + describe('and no callback is specified', function () { + describe('with a valid db index', function () { + it('selects the appropriate database', function (done) { + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); client.select(1); setTimeout(function () { - assert.equal(client.selected_db, 1, "we should have selected the new valid DB"); + assert.equal(client.selected_db, 1, 'we should have selected the new valid DB'); return done(); }, 100); }); }); - describe("with an invalid db index", function () { - it("emits an error when callback not provided", function (done) { - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + describe('with an invalid db index', function () { + it('emits an error when callback not provided', function (done) { + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); client.on('error', function (err) { assert.strictEqual(err.command, 'SELECT'); @@ -106,9 +106,9 @@ describe("The 'select' method", function () { }); }); - describe("reconnection occurs", function () { - it("selects the appropriate database after a reconnect", function (done) { - assert.strictEqual(client.selected_db, undefined, "default db should be undefined"); + describe('reconnection occurs', function () { + it('selects the appropriate database after a reconnect', function (done) { + assert.strictEqual(client.selected_db, undefined, 'default db should be undefined'); client.select(3); client.set('foo', 'bar', function () { client.stream.destroy(); diff --git a/test/commands/set.spec.js b/test/commands/set.spec.js index 8cf6fe6cd1..94b6cd69df 100644 --- a/test/commands/set.spec.js +++ b/test/commands/set.spec.js @@ -1,16 +1,16 @@ 'use strict'; var assert = require('assert'); -var config = require("../lib/config"); +var config = require('../lib/config'); var helper = require('../helper'); var redis = config.redis; var uuid = require('uuid'); describe("The 'set' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var key, value; beforeEach(function () { @@ -18,18 +18,18 @@ describe("The 'set' method", function () { value = uuid.v4(); }); - describe("when not connected", function () { + describe('when not connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.on('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { client.set(key, value, function (err, res) { assert(err.message.match(/The connection has already been closed/)); done(); @@ -37,12 +37,12 @@ describe("The 'set' method", function () { }); }); - describe("when connected", function () { + describe('when connected', function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { done(); }); }); @@ -51,9 +51,9 @@ describe("The 'set' method", function () { client.end(true); }); - describe("and a callback is specified", function () { - describe("with valid parameters", function () { - it("sets the value correctly", function (done) { + describe('and a callback is specified', function () { + describe('with valid parameters', function () { + it('sets the value correctly', function (done) { client.SET(key, value, function (err, res) { helper.isNotError()(err, res); client.get(key, function (err, res) { @@ -64,7 +64,7 @@ describe("The 'set' method", function () { }); }); - describe("reports an error with invalid parameters", function () { + describe('reports an error with invalid parameters', function () { it("undefined 'key' and missing 'value' parameter", function (done) { client.set(undefined, function (err, res) { helper.isError()(err, null); @@ -73,7 +73,7 @@ describe("The 'set' method", function () { }); }); - it("empty array as second parameter", function (done) { + it('empty array as second parameter', function (done) { client.set('foo', [], function (err, res) { assert.strictEqual(err.message, "ERR wrong number of arguments for 'set' command"); done(); @@ -82,26 +82,26 @@ describe("The 'set' method", function () { }); }); - describe("and no callback is specified", function () { - describe("with valid parameters", function () { - it("sets the value correctly", function (done) { + describe('and no callback is specified', function () { + describe('with valid parameters', function () { + it('sets the value correctly', function (done) { client.set(key, value); client.get(key, helper.isString(value, done)); }); - it("sets the value correctly even if the callback is explicitly set to undefined", function (done) { + it('sets the value correctly even if the callback is explicitly set to undefined', function (done) { client.set(key, value, undefined); client.get(key, helper.isString(value, done)); }); - it("sets the value correctly with the array syntax", function (done) { + it('sets the value correctly with the array syntax', function (done) { client.set([key, value]); client.get(key, helper.isString(value, done)); }); }); describe("with undefined 'key' and missing 'value' parameter", function () { - it("emits an error without callback", function (done) { + it('emits an error without callback', function (done) { client.on('error', function (err) { assert.equal(err.message, "ERR wrong number of arguments for 'set' command"); assert.equal(err.command, 'SET'); @@ -117,7 +117,7 @@ describe("The 'set' method", function () { client.get('foo', helper.isString('null', done)); }); - it("emit an error with only the key set", function (done) { + it('emit an error with only the key set', function (done) { client.on('error', function (err) { assert.equal(err.message, "ERR wrong number of arguments for 'set' command"); done(); @@ -126,8 +126,8 @@ describe("The 'set' method", function () { client.set('foo'); }); - it("emit an error without any parameters", function (done) { - client.once("error", function (err) { + it('emit an error without any parameters', function (done) { + client.once('error', function (err) { assert.equal(err.message, "ERR wrong number of arguments for 'set' command"); assert.equal(err.command, 'SET'); done(); diff --git a/test/commands/setex.spec.js b/test/commands/setex.spec.js index 72019ae926..9a3bb53f0b 100644 --- a/test/commands/setex.spec.js +++ b/test/commands/setex.spec.js @@ -1,27 +1,27 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'setex' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('sets a key with an expiry', function (done) { - client.setex(["setex key", "100", "setex val"], helper.isString("OK")); - var buffering = client.exists(["setex key"], helper.isNumber(1)); + client.setex(['setex key', '100', 'setex val'], helper.isString('OK')); + var buffering = client.exists(['setex key'], helper.isNumber(1)); assert(typeof buffering === 'boolean'); client.ttl(['setex key'], function (err, ttl) { assert(ttl > 0); diff --git a/test/commands/setnx.spec.js b/test/commands/setnx.spec.js index 5468463b0a..2bce9f0a0b 100644 --- a/test/commands/setnx.spec.js +++ b/test/commands/setnx.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'setnx' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/sinter.spec.js b/test/commands/sinter.spec.js index bd7c934fdc..b614a41ea4 100644 --- a/test/commands/sinter.spec.js +++ b/test/commands/sinter.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sinter' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/sinterstore.spec.js b/test/commands/sinterstore.spec.js index 434bab9a60..de7de87e10 100644 --- a/test/commands/sinterstore.spec.js +++ b/test/commands/sinterstore.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sinterstore' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/sismember.spec.js b/test/commands/sismember.spec.js index 0ba5af6402..69482b3b56 100644 --- a/test/commands/sismember.spec.js +++ b/test/commands/sismember.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sismember' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/slowlog.spec.js b/test/commands/slowlog.spec.js index e381ca28cf..7f5417dbd8 100644 --- a/test/commands/slowlog.spec.js +++ b/test/commands/slowlog.spec.js @@ -1,34 +1,34 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'slowlog' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('logs operations in slowlog', function (done) { - client.config("set", "slowlog-log-slower-than", 0, helper.isString("OK")); - client.slowlog("reset", helper.isString("OK")); - client.set("foo", "bar", helper.isString("OK")); - client.get("foo", helper.isString("bar")); - client.SLOWLOG("get", function (err, res) { + client.config('set', 'slowlog-log-slower-than', 0, helper.isString('OK')); + client.slowlog('reset', helper.isString('OK')); + client.set('foo', 'bar', helper.isString('OK')); + client.get('foo', helper.isString('bar')); + client.SLOWLOG('get', function (err, res) { assert.equal(res.length, 3); assert.equal(res[0][3].length, 2); - assert.deepEqual(res[1][3], ["set", "foo", "bar"]); - assert.deepEqual(res[2][3], ["slowlog", "reset"]); + assert.deepEqual(res[1][3], ['set', 'foo', 'bar']); + assert.deepEqual(res[2][3], ['slowlog', 'reset']); return done(err); }); }); diff --git a/test/commands/smembers.spec.js b/test/commands/smembers.spec.js index aab0989579..8fbdcbba5e 100644 --- a/test/commands/smembers.spec.js +++ b/test/commands/smembers.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'smembers' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/smove.spec.js b/test/commands/smove.spec.js index ca2c6ae256..eb8eae1054 100644 --- a/test/commands/smove.spec.js +++ b/test/commands/smove.spec.js @@ -1,19 +1,19 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'smove' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -25,7 +25,7 @@ describe("The 'smove' method", function () { client.sismember('bar', 'x', helper.isNumber(1, done)); }); - it("does not move a value if it does not exist in the first set", function (done) { + it('does not move a value if it does not exist in the first set', function (done) { client.sadd('foo', 'x', helper.isNumber(1)); client.SMOVE('foo', 'bar', 'y', helper.isNumber(0)); client.sismember('foo', 'y', helper.isNumber(0)); diff --git a/test/commands/sort.spec.js b/test/commands/sort.spec.js index 1a72664d9e..63b933eaef 100644 --- a/test/commands/sort.spec.js +++ b/test/commands/sort.spec.js @@ -1,11 +1,11 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; -function setupData(client, done) { +function setupData (client, done) { client.rpush('y', 'd'); client.rpush('y', 'b'); client.rpush('y', 'a'); @@ -34,15 +34,15 @@ function setupData(client, done) { describe("The 'sort' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("error", done); - client.once("connect", function () { + client.once('error', done); + client.once('connect', function () { client.flushdb(); setupData(client, done); }); diff --git a/test/commands/spop.spec.js b/test/commands/spop.spec.js index 224869e5b6..6e0697c02a 100644 --- a/test/commands/spop.spec.js +++ b/test/commands/spop.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'spop' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/srem.spec.js b/test/commands/srem.spec.js index 7db8b6a847..97c40d9ce2 100644 --- a/test/commands/srem.spec.js +++ b/test/commands/srem.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'srem' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -30,33 +30,33 @@ describe("The 'srem' method", function () { }); it('allows multiple values to be removed', function (done) { - client.sadd("set0", ["member0", "member1", "member2"], helper.isNumber(3)); - client.SREM("set0", ["member1", "member2"], helper.isNumber(2)); - client.smembers("set0", function (err, res) { + client.sadd('set0', ['member0', 'member1', 'member2'], helper.isNumber(3)); + client.SREM('set0', ['member1', 'member2'], helper.isNumber(2)); + client.smembers('set0', function (err, res) { assert.strictEqual(res.length, 1); - assert.ok(~res.indexOf("member0")); + assert.ok(~res.indexOf('member0')); return done(err); }); }); it('allows multiple values to be removed with send_command', function (done) { client.send_command('sadd', ['set0', 'member0', 'member1', 'member2'], helper.isNumber(3)); - client.send_command('srem', ["set0", "member1", "member2"], helper.isNumber(2)); - client.smembers("set0", function (err, res) { + client.send_command('srem', ['set0', 'member1', 'member2'], helper.isNumber(2)); + client.smembers('set0', function (err, res) { assert.strictEqual(res.length, 1); - assert.ok(~res.indexOf("member0")); + assert.ok(~res.indexOf('member0')); return done(err); }); }); it('handles a value missing from the set of values being removed', function (done) { - client.sadd(["set0", "member0", "member1", "member2"], helper.isNumber(3)); - client.SREM(["set0", "member3", "member4"], helper.isNumber(0)); - client.smembers("set0", function (err, res) { + client.sadd(['set0', 'member0', 'member1', 'member2'], helper.isNumber(3)); + client.SREM(['set0', 'member3', 'member4'], helper.isNumber(0)); + client.smembers('set0', function (err, res) { assert.strictEqual(res.length, 3); - assert.ok(~res.indexOf("member0")); - assert.ok(~res.indexOf("member1")); - assert.ok(~res.indexOf("member2")); + assert.ok(~res.indexOf('member0')); + assert.ok(~res.indexOf('member1')); + assert.ok(~res.indexOf('member2')); return done(err); }); }); diff --git a/test/commands/sunion.spec.js b/test/commands/sunion.spec.js index 835c258f21..44f5f24720 100644 --- a/test/commands/sunion.spec.js +++ b/test/commands/sunion.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sunion' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/sunionstore.spec.js b/test/commands/sunionstore.spec.js index cbef9084fe..c9869bdf88 100644 --- a/test/commands/sunionstore.spec.js +++ b/test/commands/sunionstore.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'sunionstore' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/commands/ttl.spec.js b/test/commands/ttl.spec.js index 3448fcf135..5309b70a1a 100644 --- a/test/commands/ttl.spec.js +++ b/test/commands/ttl.spec.js @@ -1,29 +1,29 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'ttl' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('returns the current ttl on a key', function (done) { - client.set(["ttl key", "ttl val"], helper.isString("OK")); - client.expire(["ttl key", "100"], helper.isNumber(1)); + client.set(['ttl key', 'ttl val'], helper.isString('OK')); + client.expire(['ttl key', '100'], helper.isNumber(1)); setTimeout(function () { - client.TTL(["ttl key"], function (err, ttl) { + client.TTL(['ttl key'], function (err, ttl) { assert.ok(ttl > 50 && ttl <= 100); return done(err); }); diff --git a/test/commands/type.spec.js b/test/commands/type.spec.js index b6336153ef..4a0c4d2897 100644 --- a/test/commands/type.spec.js +++ b/test/commands/type.spec.js @@ -1,50 +1,50 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'type' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('reports string type', function (done) { - client.set(["string key", "should be a string"], helper.isString("OK")); - client.TYPE(["string key"], helper.isString("string", done)); + client.set(['string key', 'should be a string'], helper.isString('OK')); + client.TYPE(['string key'], helper.isString('string', done)); }); it('reports list type', function (done) { - client.rpush(["list key", "should be a list"], helper.isNumber(1)); - client.type(["list key"], helper.isString("list", done)); + client.rpush(['list key', 'should be a list'], helper.isNumber(1)); + client.type(['list key'], helper.isString('list', done)); }); it('reports set type', function (done) { - client.sadd(["set key", "should be a set"], helper.isNumber(1)); - client.TYPE(["set key"], helper.isString("set", done)); + client.sadd(['set key', 'should be a set'], helper.isNumber(1)); + client.TYPE(['set key'], helper.isString('set', done)); }); it('reports zset type', function (done) { - client.zadd("zset key", ["10.0", "should be a zset"], helper.isNumber(1)); - client.TYPE(["zset key"], helper.isString("zset", done)); + client.zadd('zset key', ['10.0', 'should be a zset'], helper.isNumber(1)); + client.TYPE(['zset key'], helper.isString('zset', done)); }); it('reports hash type', function (done) { - client.hset("hash key", "hashtest", "should be a hash", helper.isNumber(1)); - client.TYPE(["hash key"], helper.isString("hash", done)); + client.hset('hash key', 'hashtest', 'should be a hash', helper.isNumber(1)); + client.TYPE(['hash key'], helper.isString('hash', done)); }); it('reports none for null key', function (done) { - client.TYPE("not here yet", helper.isString("none", done)); + client.TYPE('not here yet', helper.isString('none', done)); }); afterEach(function () { diff --git a/test/commands/watch.spec.js b/test/commands/watch.spec.js index 7214c9c8f3..cf90864675 100644 --- a/test/commands/watch.spec.js +++ b/test/commands/watch.spec.js @@ -1,22 +1,22 @@ 'use strict'; -var assert = require("assert"); -var config = require("../lib/config"); -var helper = require("../helper"); +var assert = require('assert'); +var config = require('../lib/config'); +var helper = require('../helper'); var redis = config.redis; describe("The 'watch' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { var watched = 'foobar'; - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -34,17 +34,17 @@ describe("The 'watch' method", function () { }); it('successfully modifies other keys independently of transaction', function (done) { - client.set("unwatched", 200); + client.set('unwatched', 200); - client.set(watched, 0); - client.watch(watched); - client.incr(watched); + client.set(watched, 0); + client.watch(watched); + client.incr(watched); - client.multi().incr(watched).exec(function (err, replies) { - assert.strictEqual(replies, null, "Aborted transaction multi-bulk reply should be null."); + client.multi().incr(watched).exec(function (err, replies) { + assert.strictEqual(replies, null, 'Aborted transaction multi-bulk reply should be null.'); - client.get("unwatched", function (err, reply) { - assert.equal(reply, 200, "Expected 200, got " + reply); + client.get('unwatched', function (err, reply) { + assert.equal(reply, 200, 'Expected 200, got ' + reply); return done(err); }); }); diff --git a/test/commands/zadd.spec.js b/test/commands/zadd.spec.js index 669d7a0641..e0153ba11b 100644 --- a/test/commands/zadd.spec.js +++ b/test/commands/zadd.spec.js @@ -1,36 +1,36 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var assert = require('assert'); var redis = config.redis; describe("The 'zadd' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); it('reports an error', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client.zadd('infinity', [+'5t', "should not be possible"], helper.isError(done)); + client.zadd('infinity', [+'5t', 'should not be possible'], helper.isError(done)); }); it('return inf / -inf', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); helper.serverVersionAtLeast.call(this, client, [3, 0, 2]); - client.zadd('infinity', [+Infinity, "should be inf"], helper.isNumber(1)); + client.zadd('infinity', [+Infinity, 'should be inf'], helper.isNumber(1)); client.zadd('infinity', ['inf', 'should be also be inf'], helper.isNumber(1)); - client.zadd('infinity', -Infinity, "should be negative inf", helper.isNumber(1)); - client.zadd('infinity', [99999999999999999999999, "should not be inf"], helper.isNumber(1)); + client.zadd('infinity', -Infinity, 'should be negative inf', helper.isNumber(1)); + client.zadd('infinity', [99999999999999999999999, 'should not be inf'], helper.isNumber(1)); client.zrange('infinity', 0, -1, 'WITHSCORES', function (err, res) { assert.equal(res[5], 'inf'); assert.equal(res[1], '-inf'); diff --git a/test/commands/zscan.spec.js b/test/commands/zscan.spec.js index b7a5936f30..6d4a1a60c8 100644 --- a/test/commands/zscan.spec.js +++ b/test/commands/zscan.spec.js @@ -7,14 +7,14 @@ var redis = config.redis; describe("The 'zscan' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); @@ -24,14 +24,14 @@ describe("The 'zscan' method", function () { helper.serverVersionAtLeast.call(this, client, [2, 8, 0]); var hash = {}; var set = []; - var zset = ["zset:1"]; + var zset = ['zset:1']; for (var i = 0; i < 500; i++) { - hash["key_" + i] = "value_" + i; - set.push("member_" + i); - zset.push(i, "z_member_" + i); + hash['key_' + i] = 'value_' + i; + set.push('member_' + i); + zset.push(i, 'z_member_' + i); } - client.hmset("hash:1", hash); - client.sadd("set:1", set); + client.hmset('hash:1', hash); + client.sadd('set:1', set); client.zadd(zset); client.zscan('zset:1', 0, 'MATCH', '*', 'COUNT', 500, function (err, res) { assert(!err); diff --git a/test/commands/zscore.spec.js b/test/commands/zscore.spec.js index 8a285fba9d..9d24d7a7cf 100644 --- a/test/commands/zscore.spec.js +++ b/test/commands/zscore.spec.js @@ -1,20 +1,20 @@ 'use strict'; -var config = require("../lib/config"); -var helper = require("../helper"); +var config = require('../lib/config'); +var helper = require('../helper'); var assert = require('assert'); var redis = config.redis; describe("The 'zscore' method", function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(done); }); }); diff --git a/test/conect.slave.spec.js b/test/conect.slave.spec.js index 28f56d9459..5264a125e6 100644 --- a/test/conect.slave.spec.js +++ b/test/conect.slave.spec.js @@ -1,9 +1,9 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); -var RedisProcess = require("./lib/redis-process"); +var RedisProcess = require('./lib/redis-process'); var rp; var path = require('path'); var redis = config.redis; @@ -38,7 +38,7 @@ describe('master slave sync', function () { multi.exec(done); }); - it("sync process and no master should delay ready being emitted for slaves", function (done) { + it('sync process and no master should delay ready being emitted for slaves', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); var port = 6381; diff --git a/test/connection.spec.js b/test/connection.spec.js index 1f60111f23..31e0cb0fed 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -1,14 +1,14 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; var intercept = require('intercept-stdout'); var net = require('net'); var client; -describe("connection tests", function () { +describe('connection tests', function () { beforeEach(function () { client = null; @@ -34,12 +34,12 @@ describe("connection tests", function () { assert.strictEqual(client.stream.listeners('error').length, 1); }); - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { - describe("on lost connection", function () { - it("emit an error after max retry attempts and do not try to reconnect afterwards", function (done) { + describe('on lost connection', function () { + it('emit an error after max retry attempts and do not try to reconnect afterwards', function (done) { var max_attempts = 4; var options = { parser: parser, @@ -49,15 +49,15 @@ describe("connection tests", function () { assert.strictEqual(Object.keys(options).length, 2); var calls = 0; - client.once('ready', function() { + client.once('ready', function () { helper.killConnection(client); }); - client.on("reconnecting", function (params) { + client.on('reconnecting', function (params) { calls++; }); - client.on('error', function(err) { + client.on('error', function (err) { if (/Redis connection in broken state: maximum connection attempts.*?exceeded./.test(err.message)) { setTimeout(function () { assert.strictEqual(calls, max_attempts - 1); @@ -67,7 +67,7 @@ describe("connection tests", function () { }); }); - it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) { + it('emit an error after max retry timeout and do not try to reconnect afterwards', function (done) { // TODO: Investigate why this test fails with windows. Reconnect is only triggered once if (process.platform === 'win32') this.skip(); @@ -78,15 +78,15 @@ describe("connection tests", function () { }); var time = 0; - client.once('ready', function() { + client.once('ready', function () { helper.killConnection(client); }); - client.on("reconnecting", function (params) { + client.on('reconnecting', function (params) { time += params.delay; }); - client.on('error', function(err) { + client.on('error', function (err) { if (/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message)) { setTimeout(function () { assert.strictEqual(client.retry_totaltime, connect_timeout); @@ -97,25 +97,25 @@ describe("connection tests", function () { }); }); - it("end connection while retry is still ongoing", function (done) { + it('end connection while retry is still ongoing', function (done) { var connect_timeout = 1000; // in ms client = redis.createClient({ parser: parser, connect_timeout: connect_timeout }); - client.once('ready', function() { + client.once('ready', function () { helper.killConnection(client); }); - client.on("reconnecting", function (params) { + client.on('reconnecting', function (params) { client.end(true); assert.strictEqual(params.times_connected, 1); setTimeout(done, 100); }); }); - it("can not connect with wrong host / port in the options object", function (done) { + it('can not connect with wrong host / port in the options object', function (done) { var options = { host: 'somewhere', port: 6379, @@ -134,21 +134,21 @@ describe("connection tests", function () { }); - it("emits error once if reconnecting after command has been executed but not yet returned without callback", function (done) { + it('emits error once if reconnecting after command has been executed but not yet returned without callback', function (done) { client = redis.createClient.apply(null, args); - client.on('error', function(err) { + client.on('error', function (err) { assert.strictEqual(err.code, 'UNCERTAIN_STATE'); done(); }); - client.on('ready', function() { - client.set("foo", 'bar'); + client.on('ready', function () { + client.set('foo', 'bar'); // Abort connection before the value returned client.stream.destroy(); }); }); - it("retry_strategy used to reconnect with individual error", function (done) { + it('retry_strategy used to reconnect with individual error', function (done) { var text = ''; var unhookIntercept = intercept(function (data) { text += data; @@ -172,7 +172,7 @@ describe("connection tests", function () { port: 9999 }); - client.on('error', function(err) { + client.on('error', function (err) { unhookIntercept(); assert.strictEqual( text, @@ -185,7 +185,7 @@ describe("connection tests", function () { }); }); - it("retry_strategy used to reconnect", function (done) { + it('retry_strategy used to reconnect', function (done) { var end = helper.callFuncAfter(done, 2); client = redis.createClient({ retry_strategy: function (options) { @@ -201,16 +201,16 @@ describe("connection tests", function () { port: 9999 }); - client.on('error', function(err) { + client.on('error', function (err) { assert.strictEqual(err.code, 'ECONNREFUSED'); end(); }); }); }); - describe("when not connected", function () { + describe('when not connected', function () { - it("emit an error after the socket timeout exceeded the connect_timeout time", function (done) { + it('emit an error after the socket timeout exceeded the connect_timeout time', function (done) { var connect_timeout = 500; // in ms var time = Date.now(); client = redis.createClient({ @@ -219,17 +219,17 @@ describe("connection tests", function () { host: '10.255.255.1', connect_timeout: connect_timeout }); - process.nextTick(function() { + process.nextTick(function () { assert.strictEqual(client.stream.listeners('timeout').length, 1); }); assert.strictEqual(client.address, '10.255.255.1:6379'); assert.strictEqual(client.connection_options.family, 4); - client.on("reconnecting", function (params) { + client.on('reconnecting', function (params) { throw new Error('No reconnect, since no connection was ever established'); }); - client.on('error', function(err) { + client.on('error', function (err) { if (err.code === 'ENETUNREACH') { // The test is run without a internet connection. Pretent it works return done(); } @@ -244,24 +244,24 @@ describe("connection tests", function () { }); }); - it("use the system socket timeout if the connect_timeout has not been provided", function () { + it('use the system socket timeout if the connect_timeout has not been provided', function () { client = redis.createClient({ parser: parser, host: '2001:db8::ff00:42:8329' // auto detect ip v6 }); assert.strictEqual(client.address, '2001:db8::ff00:42:8329:6379'); assert.strictEqual(client.connection_options.family, 6); - process.nextTick(function() { + process.nextTick(function () { assert.strictEqual(client.stream.listeners('timeout').length, 0); }); }); - it("clears the socket timeout after a connection has been established", function (done) { + it('clears the socket timeout after a connection has been established', function (done) { client = redis.createClient({ parser: parser, connect_timeout: 1000 }); - process.nextTick(function() { + process.nextTick(function () { assert.strictEqual(client.stream._idleTimeout, 1000); }); client.on('connect', function () { @@ -271,7 +271,7 @@ describe("connection tests", function () { }); }); - it("connect with host and port provided in the options object", function (done) { + it('connect with host and port provided in the options object', function (done) { client = redis.createClient({ host: 'localhost', port: '6379', @@ -282,7 +282,7 @@ describe("connection tests", function () { client.once('ready', done); }); - it("connect with path provided in the options object", function (done) { + it('connect with path provided in the options object', function (done) { if (process.platform === 'win32') { this.skip(); } @@ -298,105 +298,105 @@ describe("connection tests", function () { client.set('foo', 'bar', end); }); - it("connects correctly with args", function (done) { + it('connects correctly with args', function (done) { client = redis.createClient.apply(null, args); - client.on("error", done); + client.on('error', done); - client.once("ready", function () { - client.removeListener("error", done); - client.get("recon 1", done); + client.once('ready', function () { + client.removeListener('error', done); + client.get('recon 1', done); }); }); - it("connects correctly with default values", function (done) { + it('connects correctly with default values', function (done) { client = redis.createClient(); - client.on("error", done); + client.on('error', done); - client.once("ready", function () { - client.removeListener("error", done); - client.get("recon 1", done); + client.once('ready', function () { + client.removeListener('error', done); + client.get('recon 1', done); }); }); - it("connects with a port only", function (done) { + it('connects with a port only', function (done) { client = redis.createClient(6379); assert.strictEqual(client.connection_options.family, 4); - client.on("error", done); + client.on('error', done); - client.once("ready", function () { - client.removeListener("error", done); - client.get("recon 1", done); + client.once('ready', function () { + client.removeListener('error', done); + client.get('recon 1', done); }); }); - it("connects correctly to localhost", function (done) { + it('connects correctly to localhost', function (done) { client = redis.createClient(null, null); - client.on("error", done); + client.on('error', done); - client.once("ready", function () { - client.removeListener("error", done); - client.get("recon 1", done); + client.once('ready', function () { + client.removeListener('error', done); + client.get('recon 1', done); }); }); - it("connects correctly to the provided host with the port set to null", function (done) { + it('connects correctly to the provided host with the port set to null', function (done) { client = redis.createClient(null, 'localhost'); - client.on("error", done); + client.on('error', done); assert.strictEqual(client.address, 'localhost:6379'); - client.once("ready", function () { + client.once('ready', function () { client.set('foo', 'bar'); - client.get('foo', function(err, res) { + client.get('foo', function (err, res) { assert.strictEqual(res, 'bar'); done(err); }); }); }); - it("connects correctly to localhost and no ready check", function (done) { + it('connects correctly to localhost and no ready check', function (done) { client = redis.createClient(undefined, undefined, { no_ready_check: true }); - client.on("error", done); + client.on('error', done); - client.once("ready", function () { + client.once('ready', function () { client.set('foo', 'bar'); - client.get('foo', function(err, res) { + client.get('foo', function (err, res) { assert.strictEqual(res, 'bar'); done(err); }); }); }); - it("connects correctly to the provided host with the port set to undefined", function (done) { + it('connects correctly to the provided host with the port set to undefined', function (done) { client = redis.createClient(undefined, 'localhost', { no_ready_check: true }); - client.on("error", done); + client.on('error', done); assert.strictEqual(client.address, 'localhost:6379'); - client.once("ready", function () { + client.once('ready', function () { client.set('foo', 'bar'); - client.get('foo', function(err, res) { + client.get('foo', function (err, res) { assert.strictEqual(res, 'bar'); done(err); }); }); }); - it("connects correctly even if the info command is not present on the redis server", function (done) { + it('connects correctly even if the info command is not present on the redis server', function (done) { client = redis.createClient.apply(null, args); client.info = function (cb) { // Mock the result cb(new Error("ERR unknown command 'info'")); }; - client.once("ready", function () { + client.once('ready', function () { assert.strictEqual(Object.keys(client.server_info).length, 0); done(); }); }); - it("fake the stream to mock redis", function () { + it('fake the stream to mock redis', function () { // This is needed for libraries that want to mock the stream like fakeredis var temp = redis.RedisClient.prototype.create_stream; var create_stream_string = String(temp); @@ -418,7 +418,7 @@ describe("connection tests", function () { it('allows connecting with the redis url to the default host and port, select db 3 and warn about duplicate db option', function (done) { client = redis.createClient('redis:///3?db=3'); assert.strictEqual(client.selected_db, '3'); - client.on("ready", done); + client.on('ready', done); }); it('allows connecting with the redis url and the default port and auth provided even though it is not required', function (done) { @@ -428,7 +428,7 @@ describe("connection tests", function () { assert.strictEqual(msg, 'Warning: Redis server does not require a password, but a password was supplied.'); end(); }); - client.on("ready", end); + client.on('ready', end); }); it('allows connecting with the redis url as first parameter and the options as second parameter', function (done) { @@ -447,7 +447,7 @@ describe("connection tests", function () { assert.strictEqual(+client.selected_db, 3); assert(!client.options.port); assert.strictEqual(client.options.host, config.HOST[ip]); - client.on("ready", done); + client.on('ready', done); }); it('allows connecting with the redis url and no auth and options as second parameter', function (done) { @@ -456,18 +456,18 @@ describe("connection tests", function () { }; client = redis.createClient('redis://' + config.HOST[ip] + ':' + config.PORT, options); assert.strictEqual(Object.keys(options).length, 1); - client.on("ready", done); + client.on('ready', done); }); it('allows connecting with the redis url and no auth and options as third parameter', function (done) { client = redis.createClient('redis://' + config.HOST[ip] + ':' + config.PORT, null, { detect_buffers: false }); - client.on("ready", done); + client.on('ready', done); }); } - it("redis still loading <= 1000ms", function (done) { + it('redis still loading <= 1000ms', function (done) { client = redis.createClient.apply(null, args); var tmp = client.info.bind(client); var end = helper.callFuncAfter(done, 3); @@ -475,7 +475,7 @@ describe("connection tests", function () { var time; // Mock original function and pretent redis is still loading client.info = function (cb) { - tmp(function(err, res) { + tmp(function (err, res) { if (!delayed) { assert(!err); client.server_info.loading = 1; @@ -487,7 +487,7 @@ describe("connection tests", function () { cb(err, res); }); }; - client.on("ready", function () { + client.on('ready', function () { var rest = Date.now() - time; assert(rest >= 498, 'Rest should be equal or above 500 ms but is: ' + rest); // setTimeout might trigger early // Be on the safe side and accept 200ms above the original value @@ -497,7 +497,7 @@ describe("connection tests", function () { }); }); - it("redis still loading > 1000ms", function (done) { + it('redis still loading > 1000ms', function (done) { client = redis.createClient.apply(null, args); var tmp = client.info.bind(client); var end = helper.callFuncAfter(done, 3); @@ -505,7 +505,7 @@ describe("connection tests", function () { var time; // Mock original function and pretent redis is still loading client.info = function (cb) { - tmp(function(err, res) { + tmp(function (err, res) { if (!delayed) { assert(!err); // Try reconnecting after one second even if redis tells us the time needed is above one second @@ -518,7 +518,7 @@ describe("connection tests", function () { cb(err, res); }); }; - client.on("ready", function () { + client.on('ready', function () { var rest = Date.now() - time; assert(rest >= 998, '`rest` should be equal or above 1000 ms but is: ' + rest); // setTimeout might trigger early // Be on the safe side and accept 200ms above the original value diff --git a/test/detect_buffers.spec.js b/test/detect_buffers.spec.js index a7c97eac11..59f6f6ae20 100644 --- a/test/detect_buffers.spec.js +++ b/test/detect_buffers.spec.js @@ -1,15 +1,15 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; -describe("detect_buffers", function () { +describe('detect_buffers', function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var args = config.configureClient(parser, ip, { detect_buffers: true @@ -17,11 +17,11 @@ describe("detect_buffers", function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("error", done); - client.once("connect", function () { + client.once('error', done); + client.once('connect', function () { client.flushdb(function (err) { - client.hmset("hash key 2", "key 1", "val 1", "key 2", "val 2"); - client.set("string key 1", "string value"); + client.hmset('hash key 2', 'key 1', 'val 1', 'key 2', 'val 2'); + client.set('string key 1', 'string value'); return done(err); }); }); @@ -34,28 +34,28 @@ describe("detect_buffers", function () { describe('get', function () { describe('first argument is a string', function () { it('returns a string', function (done) { - client.get("string key 1", helper.isString("string value", done)); + client.get('string key 1', helper.isString('string value', done)); }); it('returns a string when executed as part of transaction', function (done) { - client.multi().get("string key 1").exec(helper.isString("string value", done)); + client.multi().get('string key 1').exec(helper.isString('string value', done)); }); }); describe('first argument is a buffer', function () { it('returns a buffer', function (done) { - client.get(new Buffer("string key 1"), function (err, reply) { + client.get(new Buffer('string key 1'), function (err, reply) { assert.strictEqual(true, Buffer.isBuffer(reply)); - assert.strictEqual("", reply.inspect()); + assert.strictEqual('', reply.inspect()); return done(err); }); }); it('returns a bufffer when executed as part of transaction', function (done) { - client.multi().get(new Buffer("string key 1")).exec(function (err, reply) { + client.multi().get(new Buffer('string key 1')).exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); - assert.strictEqual("", reply[0].inspect()); + assert.strictEqual('', reply[0].inspect()); return done(err); }); }); @@ -65,19 +65,19 @@ describe("detect_buffers", function () { describe('multi.hget', function () { it('can interleave string and buffer results', function (done) { client.multi() - .hget("hash key 2", "key 1") - .hget(new Buffer("hash key 2"), "key 1") - .hget("hash key 2", new Buffer("key 2")) - .hget("hash key 2", "key 2") + .hget('hash key 2', 'key 1') + .hget(new Buffer('hash key 2'), 'key 1') + .hget('hash key 2', new Buffer('key 2')) + .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(4, reply.length); - assert.strictEqual("val 1", reply[0]); + assert.strictEqual('val 1', reply[0]); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[1].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[2])); - assert.strictEqual("", reply[2].inspect()); - assert.strictEqual("val 2", reply[3]); + assert.strictEqual('', reply[2].inspect()); + assert.strictEqual('val 2', reply[3]); return done(err); }); }); @@ -86,19 +86,19 @@ describe("detect_buffers", function () { describe('batch.hget', function () { it('can interleave string and buffer results', function (done) { client.batch() - .hget("hash key 2", "key 1") - .hget(new Buffer("hash key 2"), "key 1") - .hget("hash key 2", new Buffer("key 2")) - .hget("hash key 2", "key 2") + .hget('hash key 2', 'key 1') + .hget(new Buffer('hash key 2'), 'key 1') + .hget('hash key 2', new Buffer('key 2')) + .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(4, reply.length); - assert.strictEqual("val 1", reply[0]); + assert.strictEqual('val 1', reply[0]); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[1].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[2])); - assert.strictEqual("", reply[2].inspect()); - assert.strictEqual("val 2", reply[3]); + assert.strictEqual('', reply[2].inspect()); + assert.strictEqual('val 2', reply[3]); return done(err); }); }); @@ -107,28 +107,28 @@ describe("detect_buffers", function () { describe('hmget', function () { describe('first argument is a string', function () { it('returns strings for keys requested', function (done) { - client.hmget("hash key 2", "key 1", "key 2", function (err, reply) { + client.hmget('hash key 2', 'key 1', 'key 2', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); - assert.strictEqual("val 1", reply[0]); - assert.strictEqual("val 2", reply[1]); + assert.strictEqual('val 1', reply[0]); + assert.strictEqual('val 2', reply[1]); return done(err); }); }); it('returns strings for keys requested in transaction', function (done) { - client.multi().hmget("hash key 2", "key 1", "key 2").exec(function (err, reply) { + client.multi().hmget('hash key 2', 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); - assert.strictEqual("val 1", reply[0][0]); - assert.strictEqual("val 2", reply[0][1]); + assert.strictEqual('val 1', reply[0][0]); + assert.strictEqual('val 2', reply[0][1]); return done(err); }); }); it('handles array of strings with undefined values (repro #344)', function (done) { - client.hmget("hash key 2", "key 3", "key 4", function(err, reply) { + client.hmget('hash key 2', 'key 3', 'key 4', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); assert.equal(null, reply[0]); @@ -138,7 +138,7 @@ describe("detect_buffers", function () { }); it('handles array of strings with undefined values in transaction (repro #344)', function (done) { - client.multi().hmget("hash key 2", "key 3", "key 4").exec(function(err, reply) { + client.multi().hmget('hash key 2', 'key 3', 'key 4').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -151,39 +151,39 @@ describe("detect_buffers", function () { describe('first argument is a buffer', function () { it('returns buffers for keys requested', function (done) { - client.hmget(new Buffer("hash key 2"), "key 1", "key 2", function (err, reply) { + client.hmget(new Buffer('hash key 2'), 'key 1', 'key 2', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[0].inspect()); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[0].inspect()); + assert.strictEqual('', reply[1].inspect()); return done(err); }); }); - it("returns buffers for keys requested in transaction", function (done) { - client.multi().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) { + it('returns buffers for keys requested in transaction', function (done) { + client.multi().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); assert.strictEqual(true, Buffer.isBuffer(reply[0][0])); assert.strictEqual(true, Buffer.isBuffer(reply[0][1])); - assert.strictEqual("", reply[0][0].inspect()); - assert.strictEqual("", reply[0][1].inspect()); + assert.strictEqual('', reply[0][0].inspect()); + assert.strictEqual('', reply[0][1].inspect()); return done(err); }); }); - it("returns buffers for keys requested in .batch", function (done) { - client.batch().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) { + it('returns buffers for keys requested in .batch', function (done) { + client.batch().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); assert.strictEqual(true, Buffer.isBuffer(reply[0][0])); assert.strictEqual(true, Buffer.isBuffer(reply[0][1])); - assert.strictEqual("", reply[0][0].inspect()); - assert.strictEqual("", reply[0][1].inspect()); + assert.strictEqual('', reply[0][0].inspect()); + assert.strictEqual('', reply[0][1].inspect()); return done(err); }); }); @@ -193,33 +193,33 @@ describe("detect_buffers", function () { describe('hgetall', function (done) { describe('first argument is a string', function () { it('returns string values', function (done) { - client.hgetall("hash key 2", function (err, reply) { - assert.strictEqual("object", typeof reply); + client.hgetall('hash key 2', function (err, reply) { + assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); - assert.strictEqual("val 1", reply["key 1"]); - assert.strictEqual("val 2", reply["key 2"]); + assert.strictEqual('val 1', reply['key 1']); + assert.strictEqual('val 2', reply['key 2']); return done(err); }); }); it('returns string values when executed in transaction', function (done) { - client.multi().hgetall("hash key 2").exec(function (err, reply) { + client.multi().hgetall('hash key 2').exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual("val 1", reply[0]["key 1"]); - assert.strictEqual("val 2", reply[0]["key 2"]); + assert.strictEqual('val 1', reply[0]['key 1']); + assert.strictEqual('val 2', reply[0]['key 2']); return done(err); }); }); it('returns string values when executed in .batch', function (done) { - client.batch().hgetall("hash key 2").exec(function (err, reply) { + client.batch().hgetall('hash key 2').exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual("val 1", reply[0]["key 1"]); - assert.strictEqual("val 2", reply[0]["key 2"]); + assert.strictEqual('val 1', reply[0]['key 1']); + assert.strictEqual('val 2', reply[0]['key 2']); return done(err); }); }); @@ -227,40 +227,40 @@ describe("detect_buffers", function () { describe('first argument is a buffer', function () { it('returns buffer values', function (done) { - client.hgetall(new Buffer("hash key 2"), function (err, reply) { + client.hgetall(new Buffer('hash key 2'), function (err, reply) { assert.strictEqual(null, err); - assert.strictEqual("object", typeof reply); + assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); - assert.strictEqual(true, Buffer.isBuffer(reply["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply["key 2"])); - assert.strictEqual("", reply["key 1"].inspect()); - assert.strictEqual("", reply["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply['key 2'])); + assert.strictEqual('', reply['key 1'].inspect()); + assert.strictEqual('', reply['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in transaction', function (done) { - client.multi().hgetall(new Buffer("hash key 2")).exec(function (err, reply) { + client.multi().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"])); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2'])); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in .batch', function (done) { - client.batch().hgetall(new Buffer("hash key 2")).exec(function (err, reply) { + client.batch().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"])); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2'])); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); @@ -268,4 +268,4 @@ describe("detect_buffers", function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/helper.js b/test/helper.js index dd30e527b0..5564a49c5e 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,10 +1,10 @@ 'use strict'; -var assert = require("assert"); +var assert = require('assert'); var path = require('path'); -var config = require("./lib/config"); -var RedisProcess = require("./lib/redis-process"); -var StunnelProcess = require("./lib/stunnel-process"); +var config = require('./lib/config'); +var RedisProcess = require('./lib/redis-process'); +var StunnelProcess = require('./lib/stunnel-process'); var rp; var stunnel_process; @@ -33,7 +33,7 @@ module.exports = { redisProcess: function () { return rp; }, - stopRedis: function(done) { + stopRedis: function (done) { rp.stop(done); }, startRedis: startRedis, @@ -52,59 +52,59 @@ module.exports = { }, isNumber: function (expected, done) { return function (err, results) { - assert.strictEqual(null, err, "expected " + expected + ", got error: " + err); - assert.strictEqual(expected, results, expected + " !== " + results); - assert.strictEqual(typeof results, "number", "expected a number, got " + typeof results); - if (done) return done(); + assert.strictEqual(null, err, 'expected ' + expected + ', got error: ' + err); + assert.strictEqual(expected, results, expected + ' !== ' + results); + assert.strictEqual(typeof results, 'number', 'expected a number, got ' + typeof results); + if (done) done(); }; }, isString: function (str, done) { return function (err, results) { assert.strictEqual(null, err, "expected string '" + str + "', got error: " + err); - assert.equal(str, results, str + " does not match " + results); - if (done) return done(); + assert.equal(str, results, str + ' does not match ' + results); + if (done) done(); }; }, isNull: function (done) { return function (err, results) { - assert.strictEqual(null, err, "expected null, got error: " + err); - assert.strictEqual(null, results, results + " is not null"); - if (done) return done(); + assert.strictEqual(null, err, 'expected null, got error: ' + err); + assert.strictEqual(null, results, results + ' is not null'); + if (done) done(); }; }, isError: function (done) { return function (err, results) { assert(err instanceof Error, "err is not instance of 'Error', but an error is expected here."); - if (done) return done(); + if (done) done(); }; }, isNotError: function (done) { return function (err, results) { - assert.strictEqual(err, null, "expected success, got an error: " + err); - if (done) return done(); + assert.strictEqual(err, null, 'expected success, got an error: ' + err); + if (done) done(); }; }, isType: { number: function (done) { return function (err, results) { - assert.strictEqual(null, err, "expected any number, got error: " + err); - assert.strictEqual(typeof results, "number", results + " is not a number"); - if (done) return done(); + assert.strictEqual(null, err, 'expected any number, got error: ' + err); + assert.strictEqual(typeof results, 'number', results + ' is not a number'); + if (done) done(); }; }, positiveNumber: function (done) { return function (err, results) { - assert.strictEqual(null, err, "expected positive number, got error: " + err); - assert.strictEqual(true, (results > 0), results + " is not a positive number"); - if (done) return done(); + assert.strictEqual(null, err, 'expected positive number, got error: ' + err); + assert.strictEqual(true, (results > 0), results + ' is not a positive number'); + if (done) done(); }; } }, match: function (pattern, done) { return function (err, results) { - assert.strictEqual(null, err, "expected " + pattern.toString() + ", got error: " + err); + assert.strictEqual(null, err, 'expected ' + pattern.toString() + ', got error: ' + err); assert(pattern.test(results), "expected string '" + results + "' to match " + pattern.toString()); - if (done) return done(); + if (done) done(); }; }, serverVersionAtLeast: function (connection, desired_version) { @@ -131,7 +131,7 @@ module.exports = { try { require('hiredis'); parsers.push('hiredis'); - } catch (e) {} + } catch (e) {/* ignore eslint */} if (process.platform !== 'win32') { protocols.push('IPv6', '/tmp/redis.sock'); } @@ -148,7 +148,7 @@ module.exports = { strOptions += key + ': ' + options[key] + '; '; } } - describe('using options: ' + strOptions, function() { + describe('using options: ' + strOptions, function () { parsers.forEach(function (parser) { protocols.forEach(function (ip, i) { if (i !== 0 && !opts.allConnections) { diff --git a/test/lib/config.js b/test/lib/config.js index ed7ef640c5..0420b032ce 100644 --- a/test/lib/config.js +++ b/test/lib/config.js @@ -13,8 +13,8 @@ var config = { redis: redis, PORT: 6379, HOST: { - IPv4: "127.0.0.1", - IPv6: "::1" + IPv4: '127.0.0.1', + IPv6: '::1' }, configureClient: function (parser, ip, opts) { var args = []; diff --git a/test/lib/redis-process.js b/test/lib/redis-process.js index a6e978494e..e98f7fbffc 100644 --- a/test/lib/redis-process.js +++ b/test/lib/redis-process.js @@ -52,11 +52,11 @@ module.exports = { var spawnFailed = false; // spawn redis with our testing configuration. var confFile = conf || path.resolve(__dirname, '../conf/redis.conf'); - var rp = spawn("redis-server", [confFile], {}); + var rp = spawn('redis-server', [confFile], {}); // capture a failure booting redis, and give // the user running the test some directions. - rp.once("exit", function (code) { + rp.once('exit', function (code) { if (code !== 0) spawnFailed = true; }); @@ -71,7 +71,7 @@ module.exports = { }, stop: function (done) { if (spawnFailed) return done(); - rp.once("exit", function (code) { + rp.once('exit', function (code) { var error = null; if (code !== null && code !== 0) { error = new Error('Redis shutdown failed with code ' + code); @@ -80,7 +80,7 @@ module.exports = { return done(error); }, port); }); - rp.kill("SIGTERM"); + rp.kill('SIGTERM'); } }); }, port); diff --git a/test/lib/stunnel-process.js b/test/lib/stunnel-process.js index f75049da17..d773f4f1de 100644 --- a/test/lib/stunnel-process.js +++ b/test/lib/stunnel-process.js @@ -12,16 +12,16 @@ if (typeof EventEmitter !== 'function') { EventEmitter = EventEmitter.EventEmitter; } -function once(cb) { +function once (cb) { var called = false; - return function() { + return function () { if (called) return; called = true; cb.apply(this, arguments); }; } -function StunnelProcess(conf_dir) { +function StunnelProcess (conf_dir) { EventEmitter.call(this); // set up an stunnel to redis; edit the conf file to include required absolute paths @@ -33,16 +33,16 @@ function StunnelProcess(conf_dir) { // handle child process events, and failure to set up tunnel var self = this; - this.timer = setTimeout(function() { + this.timer = setTimeout(function () { self.emit('error', new Error('Timeout waiting for stunnel to start')); }, 8000); - stunnel.on('error', function(err) { + stunnel.on('error', function (err) { self.clear(); self.emit('error', err); }); - stunnel.on('exit', function(code) { + stunnel.on('exit', function (code) { self.clear(); if (code === 0) { self.emit('stopped'); @@ -52,7 +52,7 @@ function StunnelProcess(conf_dir) { }); // wait to stunnel to start - stunnel.stderr.on("data", function(data) { + stunnel.stderr.on('data', function (data) { if (data.toString().match(/Service.+redis.+bound/)) { clearTimeout(this.timer); self.emit('started'); @@ -61,25 +61,25 @@ function StunnelProcess(conf_dir) { } util.inherits(StunnelProcess, EventEmitter); -StunnelProcess.prototype.clear = function() { +StunnelProcess.prototype.clear = function () { this.stunnel = null; clearTimeout(this.timer); }; -StunnelProcess.prototype.stop = function(done) { +StunnelProcess.prototype.stop = function (done) { if (this.stunnel) { this.stunnel.kill(); } }; module.exports = { - start: function(done, conf_dir) { + start: function (done, conf_dir) { done = once(done); var stunnel = new StunnelProcess(conf_dir); stunnel.once('error', done.bind(done)); stunnel.once('started', done.bind(done, null, stunnel)); }, - stop: function(stunnel, done) { + stop: function (stunnel, done) { stunnel.removeAllListeners(); stunnel.stop(); stunnel.once('error', done.bind(done)); diff --git a/test/lib/unref.js b/test/lib/unref.js index 2fb24bd748..5ad176238e 100644 --- a/test/lib/unref.js +++ b/test/lib/unref.js @@ -3,15 +3,15 @@ // as soon as there are no outstanding commands. 'use strict'; -var redis = require("../../index"); +var redis = require('../../index'); var HOST = process.argv[2] || '127.0.0.1'; var PORT = process.argv[3]; var args = PORT ? [PORT, HOST] : [HOST]; var c = redis.createClient.apply(redis, args); c.info(function (err, reply) { - if (err) process.exit(-1); - if (!reply.length) process.exit(-1); - process.stdout.write(reply.length.toString()); + if (err) process.exit(-1); + if (!reply.length) process.exit(-1); + process.stdout.write(reply.length.toString()); }); c.unref(); diff --git a/test/multi.spec.js b/test/multi.spec.js index 20be0325a7..a94c2bae99 100644 --- a/test/multi.spec.js +++ b/test/multi.spec.js @@ -1,11 +1,10 @@ 'use strict'; var assert = require('assert'); -var config = require("./lib/config"); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; var zlib = require('zlib'); -var uuid = require('uuid'); var client; describe("The 'multi' method", function () { @@ -23,14 +22,14 @@ describe("The 'multi' method", function () { // Some random object created from http://beta.json-generator.com/ var test_obj = { - "_id": "5642c4c33d4667c4a1fefd99","index": 0, "guid": "5baf1f1c-7621-41e7-ae7a-f8c6f3199b0f", "isActive": true, - "balance": "$1,028.63", "picture": "http://placehold.it/32x32", "age": 31, "eyeColor": "green", "name": {"first": "Shana", "last": "Long"}, - "company": "MANGLO", "email": "shana.long@manglo.us", "phone": "+1 (926) 405-3105", "address": "747 Dank Court, Norfolk, Ohio, 1112", - "about": "Eu pariatur in nisi occaecat enim qui consequat nostrud cupidatat id. " + - "Commodo commodo dolore esse irure minim quis deserunt anim laborum aute deserunt et est. Quis nisi laborum deserunt nisi quis.", - "registered": "Friday, April 18, 2014 9:56 AM", "latitude": "74.566613", "longitude": "-11.660432", "tags": [7, "excepteur"], - "range": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "friends": [3, {"id": 1, "name": "Schultz Dyer"}], - "greeting": "Hello, Shana! You have 5 unread messages.", "favoriteFruit": "strawberry" + '_id': '5642c4c33d4667c4a1fefd99', 'index': 0, 'guid': '5baf1f1c-7621-41e7-ae7a-f8c6f3199b0f', 'isActive': true, + 'balance': '$1,028.63', 'picture': 'http://placehold.it/32x32', 'age': 31, 'eyeColor': 'green', 'name': {'first': 'Shana', 'last': 'Long'}, + 'company': 'MANGLO', 'email': 'shana.long@manglo.us', 'phone': '+1 (926) 405-3105', 'address': '747 Dank Court, Norfolk, Ohio, 1112', + 'about': 'Eu pariatur in nisi occaecat enim qui consequat nostrud cupidatat id. ' + + 'Commodo commodo dolore esse irure minim quis deserunt anim laborum aute deserunt et est. Quis nisi laborum deserunt nisi quis.', + 'registered': 'Friday, April 18, 2014 9:56 AM', 'latitude': '74.566613', 'longitude': '-11.660432', 'tags': [7, 'excepteur'], + 'range': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 'friends': [3, {'id': 1, 'name': 'Schultz Dyer'}], + 'greeting': 'Hello, Shana! You have 5 unread messages.', 'favoriteFruit': 'strawberry' }; function run () { @@ -39,7 +38,8 @@ describe("The 'multi' method", function () { } // To demonstrate a big payload for hash set field values, let's create a big array var test_arr = []; - for (var i = 0; i < 80; i++) { + var i = 0; + for (; i < 80; i++) { var new_obj = JSON.parse(JSON.stringify(test_obj)); test_arr.push(new_obj); } @@ -92,27 +92,21 @@ describe("The 'multi' method", function () { }); - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { - var key, value; + describe('using ' + parser + ' and ' + ip, function () { - beforeEach(function () { - key = uuid.v4(); - value = uuid.v4(); - }); - - describe("when not connected", function () { + describe('when not connected', function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.quit(); }); client.once('end', done); }); - it("reports an error", function (done) { + it('reports an error', function (done) { var multi = client.multi(); var notBuffering = multi.exec(function (err, res) { assert(err.message.match(/The connection has already been closed/)); @@ -121,33 +115,33 @@ describe("The 'multi' method", function () { assert.strictEqual(notBuffering, false); }); - it("reports an error if promisified", function () { - return client.multi().execAsync().catch(function(err) { + it('reports an error if promisified', function () { + return client.multi().execAsync().catch(function (err) { assert(err.message.match(/The connection has already been closed/)); }); }); }); - describe("when connected", function () { + describe('when connected', function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("connect", done); + client.once('connect', done); }); - it("executes a pipelined multi properly in combination with the offline queue", function (done) { + it('executes a pipelined multi properly in combination with the offline queue', function (done) { var multi1 = client.multi(); - multi1.set("m1", "123"); + multi1.set('m1', '123'); multi1.get('m1'); multi1.exec(done); }); - it("executes a pipelined multi properly after a reconnect in combination with the offline queue", function (done) { + it('executes a pipelined multi properly after a reconnect in combination with the offline queue', function (done) { client.once('ready', function () { client.stream.destroy(); var called = false; var multi1 = client.multi(); - multi1.set("m1", "123"); + multi1.set('m1', '123'); multi1.get('m1'); multi1.exec(function (err, res) { assert(!err); @@ -155,7 +149,7 @@ describe("The 'multi' method", function () { }); client.once('ready', function () { var multi1 = client.multi(); - multi1.set("m2", "456"); + multi1.set('m2', '456'); multi1.get('m2'); multi1.exec(function (err, res) { assert(called); @@ -168,16 +162,16 @@ describe("The 'multi' method", function () { }); }); - describe("when connection is broken", function () { + describe('when connection is broken', function () { - it("return an error even if connection is in broken mode if callback is present", function (done) { + it('return an error even if connection is in broken mode if callback is present', function (done) { client = redis.createClient({ host: 'somewhere', port: 6379, max_attempts: 1 }); - client.on('error', function(err) { + client.on('error', function (err) { if (/Redis connection in broken state/.test(err.message)) { done(); } @@ -189,14 +183,14 @@ describe("The 'multi' method", function () { }); }); - it("does not emit an error twice if connection is in broken mode with no callback", function (done) { + it('does not emit an error twice if connection is in broken mode with no callback', function (done) { client = redis.createClient({ host: 'somewhere', port: 6379, max_attempts: 1 }); - client.on('error', function(err) { + client.on('error', function (err) { // Results in multiple done calls if test fails if (/Redis connection in broken state/.test(err.message)) { done(); @@ -207,18 +201,18 @@ describe("The 'multi' method", function () { }); }); - describe("when ready", function () { + describe('when ready', function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("ready", function () { + client.once('ready', function () { client.flushdb(function (err) { return done(err); }); }); }); - it("returns an empty result array", function (done) { + it('returns an empty result array', function (done) { var multi = client.multi(); var notBuffering = multi.exec(function (err, res) { assert.strictEqual(err, null); @@ -228,43 +222,43 @@ describe("The 'multi' method", function () { assert.strictEqual(notBuffering, true); }); - it("runs normal calls in-between multis", function (done) { + it('runs normal calls in-between multis', function (done) { var multi1 = client.multi(); - multi1.set("m1", "123"); + multi1.set('m1', '123'); client.set('m2', '456', done); }); - it("runs simultaneous multis with the same client", function (done) { + it('runs simultaneous multis with the same client', function (done) { var end = helper.callFuncAfter(done, 2); var multi1 = client.multi(); - multi1.set("m1", "123"); + multi1.set('m1', '123'); multi1.get('m1'); var multi2 = client.multi(); - multi2.set("m2", "456"); + multi2.set('m2', '456'); multi2.get('m2'); multi1.exec(end); - multi2.exec(function(err, res) { + multi2.exec(function (err, res) { assert.strictEqual(res[1], '456'); end(); }); }); - it("runs simultaneous multis with the same client version 2", function (done) { + it('runs simultaneous multis with the same client version 2', function (done) { var end = helper.callFuncAfter(done, 2); var multi2 = client.multi(); var multi1 = client.multi(); - multi2.set("m2", "456"); - multi1.set("m1", "123"); + multi2.set('m2', '456'); + multi1.set('m1', '123'); multi1.get('m1'); multi2.get('m2'); multi2.ping(); multi1.exec(end); - multi2.exec(function(err, res) { + multi2.exec(function (err, res) { assert.strictEqual(res[1], '456'); end(); }); @@ -274,11 +268,11 @@ describe("The 'multi' method", function () { var multi1, multi2; // Provoke an error at queue time multi1 = client.MULTI(); - multi1.mset("multifoo", "10", "multibar", "20", helper.isString("OK")); + multi1.mset('multifoo', '10', 'multibar', '20', helper.isString('OK')); - multi1.set("foo2", helper.isError()); - multi1.incr("multifoo"); - multi1.incr("multibar"); + multi1.set('foo2', helper.isError()); + multi1.incr('multifoo'); + multi1.incr('multibar'); multi1.exec(function () { // Redis 2.6.5+ will abort transactions with errors // see: http://redis.io/topics/transactions @@ -286,8 +280,8 @@ describe("The 'multi' method", function () { var multifoo_expected = 1; // Confirm that the previous command, while containing an error, still worked. multi2 = client.multi(); - multi2.incr("multibar", helper.isNumber(multibar_expected)); - multi2.incr("multifoo", helper.isNumber(multifoo_expected)); + multi2.incr('multibar', helper.isNumber(multibar_expected)); + multi2.incr('multifoo', helper.isNumber(multifoo_expected)); multi2.exec(function (err, replies) { assert.strictEqual(multibar_expected, replies[0]); assert.strictEqual(multifoo_expected, replies[1]); @@ -299,14 +293,14 @@ describe("The 'multi' method", function () { it('roles back a transaction when one command in an array of commands fails', function (done) { // test nested multi-bulk replies client.multi([ - ["mget", "multifoo", "multibar", function (err, res) { + ['mget', 'multifoo', 'multibar', function (err, res) { assert.strictEqual(2, res.length); assert.strictEqual(0, +res[0]); assert.strictEqual(0, +res[1]); }], - ["set", "foo2", helper.isError()], - ["incr", "multifoo"], - ["incr", "multibar"] + ['set', 'foo2', helper.isError()], + ['incr', 'multifoo'], + ['incr', 'multibar'] ]).exec(function (err, replies) { assert.notEqual(err, null); assert.equal(replies, undefined); @@ -315,25 +309,25 @@ describe("The 'multi' method", function () { }); it('handles multiple operations being applied to a set', function (done) { - client.sadd("some set", "mem 1"); - client.sadd(["some set", "mem 2"]); - client.sadd("some set", "mem 3"); - client.sadd("some set", "mem 4"); + client.sadd('some set', 'mem 1'); + client.sadd(['some set', 'mem 2']); + client.sadd('some set', 'mem 3'); + client.sadd('some set', 'mem 4'); // make sure empty mb reply works - client.del("some missing set"); - client.smembers("some missing set", function (err, reply) { + client.del('some missing set'); + client.smembers('some missing set', function (err, reply) { // make sure empty mb reply works assert.strictEqual(0, reply.length); }); // test nested multi-bulk replies with empty mb elements. client.multi([ - ["smembers", ["some set"]], - ["del", "some set"], - ["smembers", "some set"] + ['smembers', ['some set']], + ['del', 'some set'], + ['smembers', 'some set'] ]) - .scard("some set") + .scard('some set') .exec(function (err, replies) { assert.strictEqual(4, replies[0].length); assert.strictEqual(0, replies[2].length); @@ -343,26 +337,26 @@ describe("The 'multi' method", function () { it('allows multiple operations to be performed using constructor with all kinds of syntax', function (done) { var now = Date.now(); - var arr = ["multihmset", "multibar", "multibaz"]; + var arr = ['multihmset', 'multibar', 'multibaz']; var arr2 = ['some manner of key', 'otherTypes']; - var arr3 = [5768, "multibarx", "multifoox"]; - var arr4 = ["mset", [578, "multibar"], helper.isString('OK')]; + var arr3 = [5768, 'multibarx', 'multifoox']; + var arr4 = ['mset', [578, 'multibar'], helper.isString('OK')]; client.multi([ arr4, - [["mset", "multifoo2", "multibar2", "multifoo3", "multibar3"], helper.isString('OK')], - ["hmset", arr], - [["hmset", "multihmset2", "multibar2", "multifoo3", "multibar3", "test"], helper.isString('OK')], - ["hmset", ["multihmset", "multibar", "multifoo"], helper.isString('OK')], - ["hmset", arr3, helper.isString('OK')], - ['hmset', now, {123456789: "abcdefghij", "some manner of key": "a type of value", "otherTypes": 555}], - ['hmset', 'key2', {"0123456789": "abcdefghij", "some manner of key": "a type of value", "otherTypes": 999}, helper.isString('OK')], - ["HMSET", "multihmset", ["multibar", "multibaz"], undefined], // undefined is used as a explicit not set callback variable - ["hmset", "multihmset", ["multibar", "multibaz"], helper.isString('OK')], + [['mset', 'multifoo2', 'multibar2', 'multifoo3', 'multibar3'], helper.isString('OK')], + ['hmset', arr], + [['hmset', 'multihmset2', 'multibar2', 'multifoo3', 'multibar3', 'test'], helper.isString('OK')], + ['hmset', ['multihmset', 'multibar', 'multifoo'], helper.isString('OK')], + ['hmset', arr3, helper.isString('OK')], + ['hmset', now, {123456789: 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 555}], + ['hmset', 'key2', {'0123456789': 'abcdefghij', 'some manner of key': 'a type of value', 'otherTypes': 999}, helper.isString('OK')], + ['HMSET', 'multihmset', ['multibar', 'multibaz'], undefined], // undefined is used as a explicit not set callback variable + ['hmset', 'multihmset', ['multibar', 'multibaz'], helper.isString('OK')], ]) .hmget(now, 123456789, 'otherTypes') - .hmget('key2', arr2, function noop() {}) + .hmget('key2', arr2, function noop () {}) .hmget(['multihmset2', 'some manner of key', 'multibar3']) - .mget('multifoo2', ['multifoo3', 'multifoo'], function(err, res) { + .mget('multifoo2', ['multifoo3', 'multifoo'], function (err, res) { assert(res[0], 'multifoo3'); assert(res[1], 'multifoo'); }) @@ -383,7 +377,7 @@ describe("The 'multi' method", function () { }); }); - it('converts a non string key to a string', function(done) { + it('converts a non string key to a string', function (done) { // TODO: Converting the key might change soon again. client.multi().hmset(true, { test: 123, @@ -391,8 +385,8 @@ describe("The 'multi' method", function () { }).exec(done); }); - it('runs a multi without any further commands', function(done) { - var buffering = client.multi().exec(function(err, res) { + it('runs a multi without any further commands', function (done) { + var buffering = client.multi().exec(function (err, res) { assert.strictEqual(err, null); assert.strictEqual(res.length, 0); done(); @@ -453,8 +447,8 @@ describe("The 'multi' method", function () { it('allows an array to be provided indicating multiple operations to perform', function (done) { // test nested multi-bulk replies with nulls. client.multi([ - ["mget", ["multifoo", "some", "random value", "keys"]], - ["incr", "multifoo"] + ['mget', ['multifoo', 'some', 'random value', 'keys']], + ['incr', 'multifoo'] ]) .exec(function (err, replies) { assert.strictEqual(replies.length, 2); @@ -465,101 +459,101 @@ describe("The 'multi' method", function () { it('allows multiple operations to be performed on a hash', function (done) { client.multi() - .hmset("multihash", "a", "foo", "b", 1) - .hmset("multihash", { - extra: "fancy", - things: "here" + .hmset('multihash', 'a', 'foo', 'b', 1) + .hmset('multihash', { + extra: 'fancy', + things: 'here' }) - .hgetall("multihash") + .hgetall('multihash') .exec(function (err, replies) { assert.strictEqual(null, err); - assert.equal("OK", replies[0]); + assert.equal('OK', replies[0]); assert.equal(Object.keys(replies[2]).length, 4); - assert.equal("foo", replies[2].a); - assert.equal("1", replies[2].b); - assert.equal("fancy", replies[2].extra); - assert.equal("here", replies[2].things); + assert.equal('foo', replies[2].a); + assert.equal('1', replies[2].b); + assert.equal('fancy', replies[2].extra); + assert.equal('here', replies[2].things); return done(); }); }); it('reports EXECABORT exceptions when they occur (while queueing)', function (done) { - client.multi().config("bar").set("foo").set("bar").exec(function (err, reply) { - assert.equal(err.code, "EXECABORT"); - assert.equal(reply, undefined, "The reply should have been discarded"); - assert(err.message.match(/^EXECABORT/), "Error message should begin with EXECABORT"); - assert.equal(err.errors.length, 2, "err.errors should have 2 items"); + client.multi().config('bar').set('foo').set('bar').exec(function (err, reply) { + assert.equal(err.code, 'EXECABORT'); + assert.equal(reply, undefined, 'The reply should have been discarded'); + assert(err.message.match(/^EXECABORT/), 'Error message should begin with EXECABORT'); + assert.equal(err.errors.length, 2, 'err.errors should have 2 items'); assert.strictEqual(err.errors[0].command, 'SET'); assert.strictEqual(err.errors[0].code, 'ERR'); assert.strictEqual(err.errors[0].position, 1); - assert(/^ERR/.test(err.errors[0].message), "Actuall error message should begin with ERR"); + assert(/^ERR/.test(err.errors[0].message), 'Actuall error message should begin with ERR'); return done(); }); }); it('reports multiple exceptions when they occur (while EXEC is running)', function (done) { - client.multi().config("bar").debug("foo").eval("return {err='this is an error'}", 0).exec(function (err, reply) { + client.multi().config('bar').debug('foo').eval("return {err='this is an error'}", 0).exec(function (err, reply) { assert.strictEqual(reply.length, 3); assert.equal(reply[0].code, 'ERR'); assert.equal(reply[0].command, 'CONFIG'); assert.equal(reply[2].code, undefined); assert.equal(reply[2].command, 'EVAL'); assert(/^this is an error/.test(reply[2].message)); - assert(/^ERR/.test(reply[0].message), "Error message should begin with ERR"); - assert(/^ERR/.test(reply[1].message), "Error message should begin with ERR"); + assert(/^ERR/.test(reply[0].message), 'Error message should begin with ERR'); + assert(/^ERR/.test(reply[1].message), 'Error message should begin with ERR'); return done(); }); }); it('reports multiple exceptions when they occur (while EXEC is running) promisified', function () { - return client.multi().config("bar").debug("foo").eval("return {err='this is an error'}", 0).execAsync().then(function (reply) { + return client.multi().config('bar').debug('foo').eval("return {err='this is an error'}", 0).execAsync().then(function (reply) { assert.strictEqual(reply.length, 3); assert.equal(reply[0].code, 'ERR'); assert.equal(reply[0].command, 'CONFIG'); assert.equal(reply[2].code, undefined); assert.equal(reply[2].command, 'EVAL'); assert(/^this is an error/.test(reply[2].message)); - assert(/^ERR/.test(reply[0].message), "Error message should begin with ERR"); - assert(/^ERR/.test(reply[1].message), "Error message should begin with ERR"); + assert(/^ERR/.test(reply[0].message), 'Error message should begin with ERR'); + assert(/^ERR/.test(reply[1].message), 'Error message should begin with ERR'); }); }); it('reports multiple exceptions when they occur (while EXEC is running) and calls cb', function (done) { var multi = client.multi(); - multi.config("bar", helper.isError()); + multi.config('bar', helper.isError()); multi.set('foo', 'bar', helper.isString('OK')); - multi.debug("foo").exec(function (err, reply) { + multi.debug('foo').exec(function (err, reply) { assert.strictEqual(reply.length, 3); assert.strictEqual(reply[0].code, 'ERR'); - assert(/^ERR/.test(reply[0].message), "Error message should begin with ERR"); - assert(/^ERR/.test(reply[2].message), "Error message should begin with ERR"); - assert.strictEqual(reply[1], "OK"); + assert(/^ERR/.test(reply[0].message), 'Error message should begin with ERR'); + assert(/^ERR/.test(reply[2].message), 'Error message should begin with ERR'); + assert.strictEqual(reply[1], 'OK'); client.get('foo', helper.isString('bar', done)); }); }); - it("emits an error if no callback has been provided and execabort error occured", function (done) { + it('emits an error if no callback has been provided and execabort error occured', function (done) { var multi = client.multi(); - multi.config("bar"); - multi.set("foo"); + multi.config('bar'); + multi.set('foo'); multi.exec(); - client.on('error', function(err) { - assert.equal(err.code, "EXECABORT"); + client.on('error', function (err) { + assert.equal(err.code, 'EXECABORT'); done(); }); }); - it("should work without any callback", function (done) { + it('should work without any callback', function (done) { var multi = client.multi(); - multi.set("baz", "binary"); - multi.set("foo", "bar"); + multi.set('baz', 'binary'); + multi.set('foo', 'bar'); multi.exec(); client.get('foo', helper.isString('bar', done)); }); - it("should not use a transaction with exec_atomic if no command is used", function () { + it('should not use a transaction with exec_atomic if no command is used', function () { var multi = client.multi(); var test = false; multi.exec_batch = function () { @@ -569,30 +563,30 @@ describe("The 'multi' method", function () { assert(test); }); - it("should not use a transaction with exec_atomic if only one command is used", function () { + it('should not use a transaction with exec_atomic if only one command is used', function () { var multi = client.multi(); var test = false; multi.exec_batch = function () { test = true; }; - multi.set("baz", "binary"); + multi.set('baz', 'binary'); multi.exec_atomic(); assert(test); }); - it("should use transaction with exec_atomic and more than one command used", function (done) { + it('should use transaction with exec_atomic and more than one command used', function (done) { var multi = client.multi(); var test = false; multi.exec_batch = function () { test = true; }; - multi.set("baz", "binary"); + multi.set('baz', 'binary'); multi.get('baz'); multi.exec_atomic(done); assert(!test); }); - it("do not mutate arguments in the multi constructor", function (done) { + it('do not mutate arguments in the multi constructor', function (done) { var input = [['set', 'foo', 'bar'], ['get', 'foo']]; client.multi(input).exec(function (err, res) { assert.strictEqual(input.length, 2); @@ -602,7 +596,7 @@ describe("The 'multi' method", function () { }); }); - it("works properly after a reconnect. issue #897", function (done) { + it('works properly after a reconnect. issue #897', function (done) { client.stream.destroy(); client.on('error', function (err) { assert.strictEqual(err.code, 'ECONNREFUSED'); @@ -616,13 +610,13 @@ describe("The 'multi' method", function () { }); }); - it("emits error once if reconnecting after multi has been executed but not yet returned without callback", function (done) { - client.on('error', function(err) { + it('emits error once if reconnecting after multi has been executed but not yet returned without callback', function (done) { + client.on('error', function (err) { assert.strictEqual(err.code, 'UNCERTAIN_STATE'); done(); }); - client.multi().set("foo", 'bar').get('foo').exec(); + client.multi().set('foo', 'bar').get('foo').exec(); // Abort connection before the value returned client.stream.destroy(); }); diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 11b35e6dc4..45f523c4eb 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -1,33 +1,33 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var utils = require('../lib/utils'); -var fork = require("child_process").fork; +var fork = require('child_process').fork; var redis = config.redis; -describe("The node_redis client", function () { +describe('The node_redis client', function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; afterEach(function () { client.end(true); }); - describe("when connected", function () { + describe('when connected', function () { beforeEach(function (done) { client = redis.createClient.apply(null, args); - client.once("connect", function () { + client.once('connect', function () { client.flushdb(done); }); }); describe('duplicate', function () { - it('check if all options got copied properly', function(done) { + it('check if all options got copied properly', function (done) { client.selected_db = 2; var client2 = client.duplicate(); assert.strictEqual(client2.selected_db, 2); @@ -44,7 +44,7 @@ describe("The node_redis client", function () { }); }); - it('check if all new options replaced the old ones', function(done) { + it('check if all new options replaced the old ones', function (done) { var client2 = client.duplicate({ no_ready_check: true }); @@ -70,7 +70,7 @@ describe("The node_redis client", function () { describe('big data', function () { // Check if the fast mode for big strings is working correct - it('safe strings that are bigger than 30000 characters', function(done) { + it('safe strings that are bigger than 30000 characters', function (done) { var str = 'foo ಠ_ಠ bar '; while (str.length < 111111) { str += str; @@ -82,7 +82,7 @@ describe("The node_redis client", function () { }); }); - it('safe strings that are bigger than 30000 characters with multi', function(done) { + it('safe strings that are bigger than 30000 characters with multi', function (done) { var str = 'foo ಠ_ಠ bar '; while (str.length < 111111) { str += str; @@ -107,24 +107,24 @@ describe("The node_redis client", function () { }); }); - describe("send_command", function () { + describe('send_command', function () { - it("omitting args should be fine in some cases", function (done) { - client.send_command("info", undefined, function(err, res) { + it('omitting args should be fine in some cases', function (done) { + client.send_command('info', undefined, function (err, res) { assert(/redis_version/.test(res)); done(); }); }); - it("using another type as cb should just work as if there were no callback parameter", function (done) { + it('using another type as cb should just work as if there were no callback parameter', function (done) { client.send_command('set', ['test', 'bla'], [true]); - client.get('test', function(err, res) { + client.get('test', function (err, res) { assert.equal(res, 'bla'); done(); }); }); - it("misusing the function should eventually throw (no command)", function (done) { + it('misusing the function should eventually throw (no command)', function (done) { client.send_command(true, 'info', function (err, res) { assert(/ERR Protocol error/.test(err.message)); assert.equal(err.command, undefined); @@ -133,8 +133,8 @@ describe("The node_redis client", function () { }); }); - it("misusing the function should eventually throw (wrong args)", function (done) { - client.send_command('info', false, function(err, res) { + it('misusing the function should eventually throw (wrong args)', function (done) { + client.send_command('info', false, function (err, res) { assert.equal(err.message, 'ERR Protocol error: invalid multibulk length'); done(); }); @@ -142,38 +142,38 @@ describe("The node_redis client", function () { }); - describe("retry_unfulfilled_commands", function () { + describe('retry_unfulfilled_commands', function () { - it("should retry all commands instead of returning an error if a command did not yet return after a connection loss", function (done) { + it('should retry all commands instead of returning an error if a command did not yet return after a connection loss', function (done) { var bclient = redis.createClient({ parser: parser, retry_unfulfilled_commands: true }); - bclient.blpop("blocking list 2", 5, function (err, value) { - assert.strictEqual(value[0], "blocking list 2"); - assert.strictEqual(value[1], "initial value"); + 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); }); bclient.once('ready', function () { setTimeout(function () { bclient.stream.destroy(); - client.rpush("blocking list 2", "initial value", helper.isNumber(1)); + client.rpush('blocking list 2', 'initial value', helper.isNumber(1)); }, 100); }); }); }); - describe(".end", function () { + describe('.end', function () { - it('used without flush / flush set to false', function(done) { + it('used without flush / flush set to false', function (done) { var finished = false; - var end = helper.callFuncAfter(function() { + var end = helper.callFuncAfter(function () { if (!finished) { done(new Error('failed')); } }, 20); - var cb = function(err, res) { + var cb = function (err, res) { assert(/The connection has already been closed/.test(err.message)); end(); }; @@ -189,11 +189,11 @@ describe("The node_redis client", function () { }, 250); }); - it('used with flush set to true', function(done) { - var end = helper.callFuncAfter(function() { + it('used with flush set to true', function (done) { + var end = helper.callFuncAfter(function () { done(); }, 20); - var cb = function(err, res) { + var cb = function (err, res) { assert(/The connection has already been closed./.test(err.message)); end(); }; @@ -207,16 +207,16 @@ describe("The node_redis client", function () { }); - describe("commands after using .quit should fail", function () { + describe('commands after using .quit should fail', function () { - it("return an error in the callback", function (done) { + it('return an error in the callback', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); // TODO: Investigate why this test is failing hard and killing mocha if using '/tmp/redis.sock'. // Seems like something is wrong with nyc while passing a socket connection to create client! client = redis.createClient(); - client.quit(function() { - client.get("foo", function(err, res) { + client.quit(function () { + client.get('foo', function (err, res) { assert(err.message.indexOf('Redis connection gone') !== -1); assert.strictEqual(client.offline_queue.length, 0); done(); @@ -224,12 +224,12 @@ describe("The node_redis client", function () { }); }); - it("return an error in the callback version two", function (done) { + it('return an error in the callback version two', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client.quit(); - setTimeout(function() { - client.get("foo", function(err, res) { + setTimeout(function () { + client.get('foo', function (err, res) { assert.strictEqual(err.message, 'GET can\'t be processed. The connection has already been closed.'); assert.strictEqual(err.command, 'GET'); assert.strictEqual(client.offline_queue.length, 0); @@ -238,64 +238,64 @@ describe("The node_redis client", function () { }, 100); }); - it("emit an error", function (done) { + it('emit an error', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client.quit(); - client.on('error', function(err) { + client.on('error', function (err) { assert.strictEqual(err.message, 'SET can\'t be processed. The connection has already been closed.'); assert.strictEqual(err.command, 'SET'); assert.strictEqual(client.offline_queue.length, 0); done(); }); - setTimeout(function() { + setTimeout(function () { client.set('foo', 'bar'); }, 50); }); }); - describe("when redis closes unexpectedly", function () { - it("reconnects and can retrieve the pre-existing data", function (done) { - client.on("reconnecting", function on_recon(params) { - client.on("connect", function on_connect() { + describe('when redis closes unexpectedly', function () { + it('reconnects and can retrieve the pre-existing data', function (done) { + client.on('reconnecting', function on_recon (params) { + client.on('connect', function on_connect () { var end = helper.callFuncAfter(function () { - client.removeListener("connect", on_connect); - client.removeListener("reconnecting", on_recon); + client.removeListener('connect', on_connect); + client.removeListener('reconnecting', on_recon); assert.strictEqual(client.server_info.db0.keys, 2); assert.strictEqual(Object.keys(client.server_info.db0).length, 3); done(); }, 4); - client.get("recon 1", helper.isString("one", end)); - client.get("recon 1", helper.isString("one", end)); - client.get("recon 2", helper.isString("two", end)); - client.get("recon 2", helper.isString("two", end)); + client.get('recon 1', helper.isString('one', end)); + client.get('recon 1', helper.isString('one', end)); + client.get('recon 2', helper.isString('two', end)); + client.get('recon 2', helper.isString('two', end)); }); }); - client.set("recon 1", "one"); - client.set("recon 2", "two", function (err, res) { + client.set('recon 1', 'one'); + client.set('recon 2', 'two', function (err, res) { // Do not do this in normal programs. This is to simulate the server closing on us. // For orderly shutdown in normal programs, do client.quit() client.stream.destroy(); }); }); - it("reconnects properly when monitoring", function (done) { - client.on("reconnecting", function on_recon(params) { - client.on("ready", function on_ready() { - assert.strictEqual(client.monitoring, true, "monitoring after reconnect"); - client.removeListener("ready", on_ready); - client.removeListener("reconnecting", on_recon); + it('reconnects properly when monitoring', function (done) { + client.on('reconnecting', function on_recon (params) { + client.on('ready', function on_ready () { + assert.strictEqual(client.monitoring, true, 'monitoring after reconnect'); + client.removeListener('ready', on_ready); + client.removeListener('reconnecting', on_recon); done(); }); }); - assert.strictEqual(client.monitoring, false, "monitoring off at start"); - client.set("recon 1", "one"); + assert.strictEqual(client.monitoring, false, 'monitoring off at start'); + client.set('recon 1', 'one'); client.monitor(function (err, res) { - assert.strictEqual(client.monitoring, true, "monitoring on after monitor()"); - client.set("recon 2", "two", function (err, res) { + assert.strictEqual(client.monitoring, true, 'monitoring on after monitor()'); + client.set('recon 2', 'two', function (err, res) { // Do not do this in normal programs. This is to simulate the server closing on us. // For orderly shutdown in normal programs, do client.quit() client.stream.destroy(); @@ -305,40 +305,40 @@ describe("The node_redis client", function () { describe("and it's subscribed to a channel", function () { // "Connection in subscriber mode, only subscriber commands may be used" - it("reconnects, unsubscribes, and can retrieve the pre-existing data", function (done) { - client.on("ready", function on_connect() { + it('reconnects, unsubscribes, and can retrieve the pre-existing data', function (done) { + client.on('ready', function on_connect () { client.unsubscribe(helper.isNotError()); client.on('unsubscribe', function (channel, count) { // we should now be out of subscriber mode. - assert.strictEqual(channel, "recon channel"); + assert.strictEqual(channel, 'recon channel'); assert.strictEqual(count, 0); client.set('foo', 'bar', helper.isString('OK', done)); }); }); - client.set("recon 1", "one"); - client.subscribe("recon channel", function (err, res) { + client.set('recon 1', 'one'); + client.subscribe('recon channel', function (err, res) { // Do not do this in normal programs. This is to simulate the server closing on us. // For orderly shutdown in normal programs, do client.quit() client.stream.destroy(); }); }); - it("reconnects, unsubscribes, and can retrieve the pre-existing data of a explicit channel", function (done) { - client.on("ready", function on_connect() { + it('reconnects, unsubscribes, and can retrieve the pre-existing data of a explicit channel', function (done) { + client.on('ready', function on_connect () { client.unsubscribe('recon channel', helper.isNotError()); client.on('unsubscribe', function (channel, count) { // we should now be out of subscriber mode. - assert.strictEqual(channel, "recon channel"); + assert.strictEqual(channel, 'recon channel'); assert.strictEqual(count, 0); client.set('foo', 'bar', helper.isString('OK', done)); }); }); - client.set("recon 1", "one"); - client.subscribe("recon channel", function (err, res) { + client.set('recon 1', 'one'); + client.subscribe('recon channel', function (err, res) { // Do not do this in normal programs. This is to simulate the server closing on us. // For orderly shutdown in normal programs, do client.quit() client.stream.destroy(); @@ -393,10 +393,10 @@ describe("The node_redis client", function () { monitorClient.flushdb(); monitorClient.monitor(function (err, res) { assert.strictEqual(res, 'OK'); - client.mget("some", "keys", "foo", "bar"); - client.set("json", JSON.stringify({ - foo: "123", - bar: "sdflkdfsjk", + client.mget('some', 'keys', 'foo', 'bar'); + client.set('json', JSON.stringify({ + foo: '123', + bar: 'sdflkdfsjk', another: false })); monitorClient.get('baz', function (err, res) { @@ -420,7 +420,7 @@ describe("The node_redis client", function () { }); }); - monitorClient.on("monitor", function (time, args, rawOutput) { + monitorClient.on('monitor', function (time, args, rawOutput) { responses.push(args); assert(utils.monitor_regex.test(rawOutput), rawOutput); if (responses.length === 6) { @@ -442,10 +442,10 @@ describe("The node_redis client", function () { monitorClient.MONITOR(function (err, res) { assert.strictEqual(res.inspect(), new Buffer('OK').inspect()); - client.mget("hello", new Buffer('world')); + client.mget('hello', new Buffer('world')); }); - monitorClient.on("monitor", function (time, args, rawOutput) { + monitorClient.on('monitor', function (time, args, rawOutput) { assert.strictEqual(typeof rawOutput, 'string'); assert(utils.monitor_regex.test(rawOutput), rawOutput); assert.deepEqual(args, ['mget', 'hello', 'world']); @@ -457,8 +457,8 @@ describe("The node_redis client", function () { it('monitors reconnects properly and works with the offline queue', function (done) { var i = 0; client.MONITOR(helper.isString('OK')); - client.mget("hello", 'world'); - client.on("monitor", function (time, args, rawOutput) { + client.mget('hello', 'world'); + client.on('monitor', function (time, args, rawOutput) { assert(utils.monitor_regex.test(rawOutput), rawOutput); assert.deepEqual(args, ['mget', 'hello', 'world']); if (i++ === 2) { @@ -466,7 +466,7 @@ describe("The node_redis client", function () { return done(); } client.stream.destroy(); - client.mget("hello", 'world'); + client.mget('hello', 'world'); }); }); @@ -490,7 +490,7 @@ describe("The node_redis client", function () { client.unsubscribe('baz'); }, 150); var called = false; - client.on("monitor", function (time, args, rawOutput) { + client.on('monitor', function (time, args, rawOutput) { responses.push(args); assert(utils.monitor_regex.test(rawOutput), rawOutput); if (responses.length === 7) { @@ -531,7 +531,7 @@ describe("The node_redis client", function () { end(); }); client.on('idle', function onIdle () { - client.removeListener("idle", onIdle); + client.removeListener('idle', onIdle); client.get('foo', helper.isString('bar', end)); }); client.set('foo', 'bar'); @@ -540,12 +540,12 @@ describe("The node_redis client", function () { describe('utf8', function () { it('handles utf-8 keys', function (done) { - var utf8_sample = "ಠ_ಠ"; - client.set(["utf8test", utf8_sample], helper.isString("OK")); - client.get(["utf8test"], function (err, obj) { - assert.strictEqual(utf8_sample, obj); - return done(err); - }); + var utf8_sample = 'ಠ_ಠ'; + client.set(['utf8test', utf8_sample], helper.isString('OK')); + client.get(['utf8test'], function (err, obj) { + assert.strictEqual(utf8_sample, obj); + return done(err); + }); }); }); }); @@ -554,14 +554,14 @@ describe("The node_redis client", function () { it('exits subprocess as soon as final command is processed', function (done) { this.timeout(12000); var args = config.HOST[ip] ? [config.HOST[ip], config.PORT] : [ip]; - var external = fork("./test/lib/unref.js", args); + var external = fork('./test/lib/unref.js', args); var id = setTimeout(function () { external.kill(); return done(Error('unref subprocess timed out')); }, 8000); - external.on("close", function (code) { + external.on('close', function (code) { clearTimeout(id); assert.strictEqual(code, 0); return done(); @@ -612,7 +612,7 @@ describe("The node_redis client", function () { it("fires client.on('ready')", function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(true, client.options.socket_nodelay); client.quit(); @@ -624,12 +624,12 @@ describe("The node_redis client", function () { it('client is functional', function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(true, client.options.socket_nodelay); - client.set(["set key 1", "set val"], helper.isString("OK")); - client.set(["set key 2", "set val"], helper.isString("OK")); - client.get(["set key 1"], helper.isString("set val")); - client.get(["set key 2"], helper.isString("set val")); + client.set(['set key 1', 'set val'], helper.isString('OK')); + client.set(['set key 2', 'set val'], helper.isString('OK')); + client.get(['set key 1'], helper.isString('set val')); + client.get(['set key 2'], helper.isString('set val')); client.quit(); client.once('end', function () { @@ -646,7 +646,7 @@ describe("The node_redis client", function () { it("fires client.on('ready')", function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(false, client.options.socket_nodelay); client.quit(); @@ -658,12 +658,12 @@ describe("The node_redis client", function () { it('client is functional', function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(false, client.options.socket_nodelay); - client.set(["set key 1", "set val"], helper.isString("OK")); - client.set(["set key 2", "set val"], helper.isString("OK")); - client.get(["set key 1"], helper.isString("set val")); - client.get(["set key 2"], helper.isString("set val")); + client.set(['set key 1', 'set val'], helper.isString('OK')); + client.set(['set key 2', 'set val'], helper.isString('OK')); + client.get(['set key 1'], helper.isString('set val')); + client.get(['set key 2'], helper.isString('set val')); client.quit(); client.once('end', function () { @@ -677,7 +677,7 @@ describe("The node_redis client", function () { it("fires client.on('ready')", function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(true, client.options.socket_nodelay); client.quit(); @@ -689,12 +689,12 @@ describe("The node_redis client", function () { it('client is functional', function (done) { client = redis.createClient.apply(null, args); - client.on("ready", function () { + client.on('ready', function () { assert.strictEqual(true, client.options.socket_nodelay); - client.set(["set key 1", "set val"], helper.isString("OK")); - client.set(["set key 2", "set val"], helper.isString("OK")); - client.get(["set key 1"], helper.isString("set val")); - client.get(["set key 2"], helper.isString("set val")); + client.set(['set key 1', 'set val'], helper.isString('OK')); + client.set(['set key 2', 'set val'], helper.isString('OK')); + client.get(['set key 1'], helper.isString('set val')); + client.get(['set key 2'], helper.isString('set val')); client.quit(); client.once('end', function () { @@ -706,14 +706,14 @@ describe("The node_redis client", function () { }); describe('retry_max_delay', function () { - it("sets upper bound on how long client waits before reconnecting", function (done) { + it('sets upper bound on how long client waits before reconnecting', function (done) { var time; var timeout = process.platform !== 'win32' ? 20 : 100; client = redis.createClient.apply(null, config.configureClient(parser, ip, { retry_max_delay: 1 // ms })); - client.on('ready', function() { + client.on('ready', function () { if (this.times_connected === 1) { this.stream.end(); time = Date.now(); @@ -735,9 +735,9 @@ describe("The node_redis client", function () { describe('protocol error', function () { - it("should gracefully recover and only fail on the already send commands", function (done) { + it('should gracefully recover and only fail on the already send commands', function (done) { client = redis.createClient.apply(null, args); - client.on('error', function(err) { + client.on('error', function (err) { assert.strictEqual(err.message, 'Protocol error, got "a" as reply type byte'); // After the hard failure work properly again. The set should have been processed properly too client.get('foo', function (err, res) { @@ -757,7 +757,7 @@ describe("The node_redis client", function () { describe('enable_offline_queue', function () { describe('true', function () { - it("should emit drain if offline queue is flushed and nothing to buffer", function (done) { + it('should emit drain if offline queue is flushed and nothing to buffer', function (done) { client = redis.createClient({ parser: parser, no_ready_check: true @@ -773,33 +773,32 @@ describe("The node_redis client", function () { ); end(); }); - client.on('drain', function() { + client.on('drain', function () { assert(client.offline_queue.length === 0); end(); }); }); - it("does not return an error and enqueues operation", function (done) { + it('does not return an error and enqueues operation', function (done) { client = redis.createClient(9999, null, { max_attempts: 0, parser: parser }); var finished = false; - client.on('error', function(e) { + client.on('error', function (e) { // ignore, b/c expecting a "can't connect" error }); - return setTimeout(function() { - client.set('foo', 'bar', function(err, result) { + return setTimeout(function () { + client.set('foo', 'bar', function (err, result) { if (!finished) { // This should never be called return done(err); - } else { - assert.strictEqual(err.message, "The command can't be processed. The connection has already been closed."); } + assert.strictEqual(err.message, "The command can't be processed. The connection has already been closed."); }); - return setTimeout(function() { + return setTimeout(function () { assert.strictEqual(client.offline_queue.length, 1); finished = true; return done(); @@ -807,14 +806,14 @@ describe("The node_redis client", function () { }, 50); }); - it("enqueues operation and keep the queue while trying to reconnect", function (done) { + it('enqueues operation and keep the queue while trying to reconnect', function (done) { client = redis.createClient(9999, null, { max_attempts: 4, parser: parser }); var i = 0; - client.on('error', function(err) { + client.on('error', function (err) { if (err.message === 'Redis connection in broken state: maximum connection attempts exceeded.') { assert(i, 3); assert.strictEqual(client.offline_queue.length, 0); @@ -826,7 +825,7 @@ describe("The node_redis client", function () { } }); - client.on('reconnecting', function(params) { + client.on('reconnecting', function (params) { i++; assert.equal(params.attempt, i); assert.strictEqual(params.times_connected, 0); @@ -837,35 +836,35 @@ describe("The node_redis client", function () { // Should work with either a callback or without client.set('baz', 13); - client.set('foo', 'bar', function(err, result) { + client.set('foo', 'bar', function (err, result) { assert(i, 3); assert(err); assert.strictEqual(client.offline_queue.length, 0); }); }); - it("flushes the command queue if connection is lost", function (done) { + it('flushes the command queue if connection is lost', function (done) { client = redis.createClient({ parser: parser }); - client.once('ready', function() { + client.once('ready', function () { var multi = client.multi(); - multi.config("bar"); - var cb = function(err, reply) { + multi.config('bar'); + var cb = function (err, reply) { assert.equal(err.code, 'UNCERTAIN_STATE'); }; for (var i = 0; i < 12; i += 3) { - client.set("foo" + i, "bar" + i); - multi.set("foo" + (i + 1), "bar" + (i + 1), cb); - multi.set("foo" + (i + 2), "bar" + (i + 2)); + client.set('foo' + i, 'bar' + i); + multi.set('foo' + (i + 1), 'bar' + (i + 1), cb); + multi.set('foo' + (i + 2), 'bar' + (i + 2)); } multi.exec(); assert.equal(client.command_queue.length, 15); helper.killConnection(client); }); - client.on('error', function(err) { + client.on('error', function (err) { if (/uncertain state/.test(err.message)) { assert.equal(client.command_queue.length, 0); done(); @@ -880,7 +879,7 @@ describe("The node_redis client", function () { describe('false', function () { - it('stream not writable', function(done) { + it('stream not writable', function (done) { client = redis.createClient({ parser: parser, enable_offline_queue: false @@ -894,7 +893,7 @@ describe("The node_redis client", function () { }); }); - it("emit an error and does not enqueues operation", function (done) { + it('emit an error and does not enqueues operation', function (done) { client = redis.createClient(9999, null, { parser: parser, max_attempts: 0, @@ -902,7 +901,7 @@ describe("The node_redis client", function () { }); var end = helper.callFuncAfter(done, 3); - client.on('error', function(err) { + client.on('error', function (err) { assert(/offline queue is deactivated|ECONNREFUSED/.test(err.message)); assert.equal(client.command_queue.length, 0); end(); @@ -919,30 +918,30 @@ describe("The node_redis client", function () { }); }); - it("flushes the command queue if connection is lost", function (done) { + it('flushes the command queue if connection is lost', function (done) { client = redis.createClient({ parser: parser, max_attempts: 2, enable_offline_queue: false }); - client.once('ready', function() { + client.once('ready', function () { var multi = client.multi(); - multi.config("bar"); - var cb = function(err, reply) { + multi.config('bar'); + var cb = function (err, reply) { assert.equal(err.code, 'UNCERTAIN_STATE'); }; for (var i = 0; i < 12; i += 3) { - client.set("foo" + i, "bar" + i); - multi.set("foo" + (i + 1), "bar" + (i + 1), cb); - multi.set("foo" + (i + 2), "bar" + (i + 2)); + client.set('foo' + i, 'bar' + i); + multi.set('foo' + (i + 1), 'bar' + (i + 1), cb); + multi.set('foo' + (i + 2), 'bar' + (i + 2)); } multi.exec(); assert.equal(client.command_queue.length, 15); helper.killConnection(client); }); - client.on('error', function(err) { + client.on('error', function (err) { if (err.code === 'UNCERTAIN_STATE') { assert.equal(client.command_queue.length, 0); done(); diff --git a/test/prefix.spec.js b/test/prefix.spec.js index 4c909f1af9..e34805a7a9 100644 --- a/test/prefix.spec.js +++ b/test/prefix.spec.js @@ -1,18 +1,18 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; -describe("prefix key names", function () { +describe('prefix key names', function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client = null; - beforeEach(function(done) { + beforeEach(function (done) { client = redis.createClient({ parser: parser, prefix: 'test:prefix:' @@ -28,14 +28,14 @@ describe("prefix key names", function () { client.end(true); }); - it("auto prefix set / get", function (done) { - client.set('key', 'value', function(err, reply) { + it('auto prefix set / get', function (done) { + client.set('key', 'value', function (err, reply) { assert.strictEqual(reply, 'OK'); }); - client.get('key', function(err, reply) { + client.get('key', function (err, reply) { assert.strictEqual(reply, 'value'); }); - client.getrange('key', 1, -1, function(err, reply) { + client.getrange('key', 1, -1, function (err, reply) { assert.strictEqual(reply, 'alue'); assert.strictEqual(err, null); }); @@ -56,15 +56,15 @@ describe("prefix key names", function () { }); }); - it("auto prefix set / get with .batch", function (done) { + it('auto prefix set / get with .batch', function (done) { var batch = client.batch(); - batch.set('key', 'value', function(err, reply) { + batch.set('key', 'value', function (err, reply) { assert.strictEqual(reply, 'OK'); }); - batch.get('key', function(err, reply) { + batch.get('key', function (err, reply) { assert.strictEqual(reply, 'value'); }); - batch.getrange('key', 1, -1, function(err, reply) { + batch.getrange('key', 1, -1, function (err, reply) { assert.strictEqual(reply, 'alue'); assert.strictEqual(err, null); }); @@ -85,15 +85,15 @@ describe("prefix key names", function () { batch.exec(done); }); - it("auto prefix set / get with .multi", function (done) { + it('auto prefix set / get with .multi', function (done) { var multi = client.multi(); - multi.set('key', 'value', function(err, reply) { + multi.set('key', 'value', function (err, reply) { assert.strictEqual(reply, 'OK'); }); - multi.get('key', function(err, reply) { + multi.get('key', function (err, reply) { assert.strictEqual(reply, 'value'); }); - multi.getrange('key', 1, -1, function(err, reply) { + multi.getrange('key', 1, -1, function (err, reply) { assert.strictEqual(reply, 'alue'); assert.strictEqual(err, null); }); diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index cefe33f5d0..63d61e01bb 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -1,32 +1,32 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); -var helper = require("./helper"); +var assert = require('assert'); +var config = require('./lib/config'); +var helper = require('./helper'); var redis = config.redis; -describe("publish/subscribe", function () { +describe('publish/subscribe', function () { - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var pub = null; var sub = null; - var channel = "test channel"; - var channel2 = "test channel 2"; - var message = "test message"; + var channel = 'test channel'; + var channel2 = 'test channel 2'; + var message = 'test message'; beforeEach(function (done) { var end = helper.callFuncAfter(done, 2); pub = redis.createClient.apply(redis.createClient, args); sub = redis.createClient.apply(redis.createClient, args); - pub.once("connect", function () { + pub.once('connect', function () { pub.flushdb(function () { end(); }); }); - sub.once("connect", function () { + sub.once('connect', function () { end(); }); }); @@ -37,14 +37,14 @@ describe("publish/subscribe", function () { sub = redis.createClient({ disable_resubscribing: true }); - sub.once("connect", function () { + sub.once('connect', function () { done(); }); }); it('does not fire subscribe events after reconnecting', function (done) { var a = false; - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { if (chnl === channel2) { if (a) { return done(new Error('Test failed')); @@ -54,7 +54,7 @@ describe("publish/subscribe", function () { } }); - sub.on('reconnecting', function() { + sub.on('reconnecting', function () { a = true; sub.on('ready', function () { setTimeout(done, 250); @@ -68,7 +68,7 @@ describe("publish/subscribe", function () { describe('subscribe', function () { it('fires a subscribe event for each channel subscribed to even after reconnecting', function (done) { var a = false; - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { if (chnl === channel2) { assert.equal(2, count); if (a) { @@ -78,7 +78,7 @@ describe("publish/subscribe", function () { } }); - sub.on('reconnecting', function() { + sub.on('reconnecting', function () { a = true; }); @@ -91,7 +91,7 @@ describe("publish/subscribe", function () { sub = redis.createClient({ detect_buffers: true }); - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { if (chnl.inspect() === new Buffer([0xAA, 0xBB, 0x00, 0xF0]).inspect()) { assert.equal(1, count); if (a) { @@ -101,7 +101,7 @@ describe("publish/subscribe", function () { } }); - sub.on('reconnecting', function() { + sub.on('reconnecting', function () { a = true; }); @@ -110,14 +110,14 @@ describe("publish/subscribe", function () { it('receives messages on subscribed channel', function (done) { var end = helper.callFuncAfter(done, 2); - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { pub.publish(channel, message, function (err, res) { helper.isNumber(1)(err, res); end(); }); }); - sub.on("message", function (chnl, msg) { + sub.on('message', function (chnl, msg) { assert.equal(chnl, channel); assert.equal(msg, message); end(); @@ -128,14 +128,14 @@ describe("publish/subscribe", function () { it('receives messages if subscribe is called after unsubscribe', function (done) { var end = helper.callFuncAfter(done, 2); - sub.once("subscribe", function (chnl, count) { + sub.once('subscribe', function (chnl, count) { pub.publish(channel, message, function (err, res) { helper.isNumber(1)(err, res); end(); }); }); - sub.on("message", function (chnl, msg) { + sub.on('message', function (chnl, msg) { assert.equal(chnl, channel); assert.equal(msg, message); end(); @@ -167,10 +167,10 @@ describe("publish/subscribe", function () { }); it('emits end event if quit is called from within subscribe', function (done) { - sub.on("end", function () { + sub.on('end', function () { return done(); }); - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { sub.quit(); }); sub.subscribe(channel); @@ -186,45 +186,45 @@ describe("publish/subscribe", function () { When it resubscribes, c2 publishes the third message, on the second channel c1 gets the message and drops its connection. When it reconnects, the test ends. */ - sub.on("message", function(channel, message) { - if (channel === "chan1") { - assert.strictEqual(message, "hi on channel 1"); + sub.on('message', function (channel, message) { + if (channel === 'chan1') { + assert.strictEqual(message, 'hi on channel 1'); sub.stream.end(); - } else if (channel === "chan2") { - assert.strictEqual(message, "hi on channel 2"); + } else if (channel === 'chan2') { + assert.strictEqual(message, 'hi on channel 2'); sub.stream.end(); } else { sub.quit(); pub.quit(); - assert.fail("test failed"); + assert.fail('test failed'); } }); - sub.subscribe("chan1", "chan2"); + sub.subscribe('chan1', 'chan2'); - sub.on("ready", function(err, results) { + sub.on('ready', function (err, results) { count++; if (count === 1) { - pub.publish("chan1", "hi on channel 1"); + pub.publish('chan1', 'hi on channel 1'); return; } else if (count === 2) { - pub.publish("chan2", "hi on channel 2"); + pub.publish('chan2', 'hi on channel 2'); } else { - sub.quit(function() { - pub.quit(function() { + sub.quit(function () { + pub.quit(function () { return done(); }); }); } }); - pub.publish("chan1", "hi on channel 1"); + pub.publish('chan1', 'hi on channel 1'); }); }); - describe("multiple subscribe / unsubscribe commands", function () { + describe('multiple subscribe / unsubscribe commands', function () { - it("reconnects properly with pub sub and select command", function (done) { + it('reconnects properly with pub sub and select command', function (done) { var end = helper.callFuncAfter(done, 2); sub.select(3); sub.set('foo', 'bar'); @@ -240,7 +240,7 @@ describe("publish/subscribe", function () { }); }); - it("should not go into pubsub mode with unsubscribe commands", function (done) { + it('should not go into pubsub mode with unsubscribe commands', function (done) { sub.on('unsubscribe', function (msg) { // The unsubscribe should not be triggered, as there was no corresponding channel throw new Error('Test failed'); @@ -252,7 +252,7 @@ describe("publish/subscribe", function () { sub.del('foo', done); }); - it("handles multiple channels with the same channel name properly, even with buffers", function (done) { + it('handles multiple channels with the same channel name properly, even with buffers', function (done) { var channels = ['a', 'b', 'a', new Buffer('a'), 'c', 'b']; var subscribed_channels = [1, 2, 2, 2, 3, 3]; var i = 0; @@ -286,14 +286,14 @@ describe("publish/subscribe", function () { }); }); - it("unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Withouth callbacks", function (done) { - function subscribe(channels) { + it('unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Withouth callbacks', function (done) { + function subscribe (channels) { sub.unsubscribe(helper.isNull); sub.subscribe(channels, helper.isNull); } var all = false; var subscribeMsg = ['1', '3', '2', '5', 'test', 'bla']; - sub.on('subscribe', function(msg, count) { + sub.on('subscribe', function (msg, count) { subscribeMsg.splice(subscribeMsg.indexOf(msg), 1); if (subscribeMsg.length === 0 && all) { assert.strictEqual(count, 3); @@ -301,7 +301,7 @@ describe("publish/subscribe", function () { } }); var unsubscribeMsg = ['1', '3', '2']; - sub.on('unsubscribe', function(msg, count) { + sub.on('unsubscribe', function (msg, count) { unsubscribeMsg.splice(unsubscribeMsg.indexOf(msg), 1); if (unsubscribeMsg.length === 0) { assert.strictEqual(count, 0); @@ -314,14 +314,14 @@ describe("publish/subscribe", function () { subscribe(['5', 'test', 'bla']); }); - it("unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Without callbacks", function (done) { - function subscribe(channels) { + it('unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Without callbacks', function (done) { + function subscribe (channels) { sub.unsubscribe(); sub.subscribe(channels); } var all = false; var subscribeMsg = ['1', '3', '2', '5', 'test', 'bla']; - sub.on('subscribe', function(msg, count) { + sub.on('subscribe', function (msg, count) { subscribeMsg.splice(subscribeMsg.indexOf(msg), 1); if (subscribeMsg.length === 0 && all) { assert.strictEqual(count, 3); @@ -329,7 +329,7 @@ describe("publish/subscribe", function () { } }); var unsubscribeMsg = ['1', '3', '2']; - sub.on('unsubscribe', function(msg, count) { + sub.on('unsubscribe', function (msg, count) { unsubscribeMsg.splice(unsubscribeMsg.indexOf(msg), 1); if (unsubscribeMsg.length === 0) { assert.strictEqual(count, 0); @@ -342,15 +342,15 @@ describe("publish/subscribe", function () { subscribe(['5', 'test', 'bla']); }); - it("unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Without callback and concret channels", function (done) { - function subscribe(channels) { + it('unsubscribes, subscribes, unsubscribes... single and multiple entries mixed. Without callback and concret channels', function (done) { + function subscribe (channels) { sub.unsubscribe(channels); sub.unsubscribe(channels); sub.subscribe(channels); } var all = false; var subscribeMsg = ['1', '3', '2', '5', 'test', 'bla']; - sub.on('subscribe', function(msg, count) { + sub.on('subscribe', function (msg, count) { subscribeMsg.splice(subscribeMsg.indexOf(msg), 1); if (subscribeMsg.length === 0 && all) { assert.strictEqual(count, 6); @@ -358,7 +358,7 @@ describe("publish/subscribe", function () { } }); var unsubscribeMsg = ['1', '3', '2', '5', 'test', 'bla']; - sub.on('unsubscribe', function(msg, count) { + sub.on('unsubscribe', function (msg, count) { var pos = unsubscribeMsg.indexOf(msg); if (pos !== -1) unsubscribeMsg.splice(pos, 1); @@ -372,8 +372,8 @@ describe("publish/subscribe", function () { subscribe(['5', 'test', 'bla']); }); - it("unsubscribes, subscribes, unsubscribes... with pattern matching", function (done) { - function subscribe(channels, callback) { + it('unsubscribes, subscribes, unsubscribes... with pattern matching', function (done) { + function subscribe (channels, callback) { sub.punsubscribe('prefix:*', helper.isNull); sub.psubscribe(channels, function (err, res) { helper.isNull(err); @@ -383,7 +383,7 @@ describe("publish/subscribe", function () { var all = false; var end = helper.callFuncAfter(done, 8); var subscribeMsg = ['prefix:*', 'prefix:3', 'prefix:2', '5', 'test:a', 'bla']; - sub.on('psubscribe', function(msg, count) { + sub.on('psubscribe', function (msg, count) { subscribeMsg.splice(subscribeMsg.indexOf(msg), 1); if (subscribeMsg.length === 0) { assert.strictEqual(count, 5); @@ -392,7 +392,7 @@ describe("publish/subscribe", function () { }); var rest = 1; var unsubscribeMsg = ['prefix:*', 'prefix:*', 'prefix:*', '*']; - sub.on('punsubscribe', function(msg, count) { + sub.on('punsubscribe', function (msg, count) { unsubscribeMsg.splice(unsubscribeMsg.indexOf(msg), 1); if (all) { assert.strictEqual(unsubscribeMsg.length, 0); @@ -434,13 +434,13 @@ describe("publish/subscribe", function () { describe('unsubscribe', function () { it('fires an unsubscribe event', function (done) { - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { sub.unsubscribe(channel); }); sub.subscribe(channel); - sub.on("unsubscribe", function (chnl, count) { + sub.on('unsubscribe', function (chnl, count) { assert.equal(chnl, channel); assert.strictEqual(count, 0); return done(); @@ -448,14 +448,14 @@ describe("publish/subscribe", function () { }); it('puts client back into write mode', function (done) { - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { sub.unsubscribe(channel); }); sub.subscribe(channel); - sub.on("unsubscribe", function (chnl, count) { - pub.incr("foo", helper.isNumber(1, done)); + sub.on('unsubscribe', function (chnl, count) { + pub.incr('foo', helper.isNumber(1, done)); }); }); @@ -484,7 +484,7 @@ describe("publish/subscribe", function () { sub2.on('ready', function () { sub2.psubscribe('*'); sub2.subscribe('/foo'); - sub2.on("pmessage", function(pattern, channel, message) { + sub2.on('pmessage', function (pattern, channel, message) { assert.strictEqual(pattern.inspect(), new Buffer('*').inspect()); assert.strictEqual(channel.inspect(), new Buffer('/foo').inspect()); assert.strictEqual(message.inspect(), new Buffer('hello world').inspect()); @@ -539,10 +539,10 @@ describe("publish/subscribe", function () { }); }); - it("should not publish a message multiple times per command", function (done) { + it('should not publish a message multiple times per command', function (done) { var published = {}; - function subscribe(message) { + function subscribe (message) { sub.removeAllListeners('subscribe'); sub.removeAllListeners('message'); sub.removeAllListeners('unsubscribe'); @@ -572,7 +572,7 @@ describe("publish/subscribe", function () { }, 40); }); - it("should not publish a message without any publish command", function (done) { + it('should not publish a message without any publish command', function (done) { pub.set('foo', 'message'); pub.set('bar', 'hello'); pub.mget('foo', 'bar'); diff --git a/test/rename.spec.js b/test/rename.spec.js index 0d3aa0cc19..b98661e9f5 100644 --- a/test/rename.spec.js +++ b/test/rename.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; @@ -10,19 +10,19 @@ if (process.platform === 'win32') { return; } -describe("rename commands", function () { +describe('rename commands', function () { before(function (done) { helper.stopRedis(function () { helper.startRedis('./conf/rename.conf', done); }); }); - helper.allTests(function(parser, ip, args) { + helper.allTests(function (parser, ip, args) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client = null; - beforeEach(function(done) { + beforeEach(function (done) { if (helper.redisProcess().spawnFailed()) return done(); client = redis.createClient({ rename_commands: { @@ -42,27 +42,27 @@ describe("rename commands", function () { client.end(true); }); - it("allows to use renamed functions", function (done) { + it('allows to use renamed functions', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); - client.set('key', 'value', function(err, reply) { + client.set('key', 'value', function (err, reply) { assert.strictEqual(reply, 'OK'); }); - client.get('key', function(err, reply) { + client.get('key', function (err, reply) { assert.strictEqual(err.message, "ERR unknown command 'get'"); assert.strictEqual(err.command, 'GET'); assert.strictEqual(reply, undefined); }); - client.getrange('key', 1, -1, function(err, reply) { + client.getrange('key', 1, -1, function (err, reply) { assert.strictEqual(reply, 'alue'); assert.strictEqual(err, null); done(); }); }); - it("should also work with batch", function (done) { + it('should also work with batch', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client.batch([['set', 'key', 'value']]).exec(function (err, res) { @@ -79,7 +79,7 @@ describe("rename commands", function () { }); }); - it("should also work with multi", function (done) { + it('should also work with multi', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client.multi([['set', 'key', 'value']]).exec(function (err, res) { @@ -96,12 +96,12 @@ describe("rename commands", function () { }); }); - it("should also work with multi and abort transaction", function (done) { + it('should also work with multi and abort transaction', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); var multi = client.multi(); multi.get('key'); - multi.getrange('key', 1, -1, function(err, reply) { + multi.getrange('key', 1, -1, function (err, reply) { assert.strictEqual(reply, 'alue'); assert.strictEqual(err, null); }); @@ -116,7 +116,7 @@ describe("rename commands", function () { }); }); - it("should also work prefixed commands", function (done) { + it('should also work prefixed commands', function (done) { if (helper.redisProcess().spawnFailed()) this.skip(); client.end(true); @@ -128,7 +128,7 @@ describe("rename commands", function () { prefix: 'baz' }); client.set('foo', 'bar'); - client.keys('*', function(err, reply) { + client.keys('*', function (err, reply) { assert.strictEqual(reply[0], 'bazfoo'); assert.strictEqual(err, null); done(); diff --git a/test/return_buffers.spec.js b/test/return_buffers.spec.js index ab12668c59..1274c8be9e 100644 --- a/test/return_buffers.spec.js +++ b/test/return_buffers.spec.js @@ -1,15 +1,15 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var helper = require('./helper'); var redis = config.redis; -describe("return_buffers", function () { +describe('return_buffers', function () { - helper.allTests(function(parser, ip, basicArgs) { + helper.allTests(function (parser, ip, basicArgs) { - describe("using " + parser + " and " + ip, function () { + describe('using ' + parser + ' and ' + ip, function () { var client; var args = config.configureClient(parser, ip, { return_buffers: true, @@ -30,11 +30,11 @@ describe("return_buffers", function () { assert.strictEqual(msg, 'WARNING: You activated return_buffers and detect_buffers at the same time. The return value is always going to be a buffer.'); end(); }); - client.once("error", done); - client.once("connect", function () { + client.once('error', done); + client.once('connect', function () { client.flushdb(function (err) { - client.hmset("hash key 2", "key 1", "val 1", "key 2", "val 2"); - client.set("string key 1", "string value"); + client.hmset('hash key 2', 'key 1', 'val 1', 'key 2', 'val 2'); + client.set('string key 1', 'string value'); end(err); }); }); @@ -43,18 +43,18 @@ describe("return_buffers", function () { describe('get', function () { describe('first argument is a string', function () { it('returns a buffer', function (done) { - client.get("string key 1", function (err, reply) { + client.get('string key 1', function (err, reply) { assert.strictEqual(true, Buffer.isBuffer(reply)); - assert.strictEqual("", reply.inspect()); + assert.strictEqual('', reply.inspect()); return done(err); }); }); it('returns a bufffer when executed as part of transaction', function (done) { - client.multi().get("string key 1").exec(function (err, reply) { + client.multi().get('string key 1').exec(function (err, reply) { assert.strictEqual(1, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); - assert.strictEqual("", reply[0].inspect()); + assert.strictEqual('', reply[0].inspect()); return done(err); }); }); @@ -64,20 +64,20 @@ describe("return_buffers", function () { describe('multi.hget', function () { it('returns buffers', function (done) { client.multi() - .hget("hash key 2", "key 1") - .hget(new Buffer("hash key 2"), "key 1") - .hget("hash key 2", new Buffer("key 2")) - .hget("hash key 2", "key 2") + .hget('hash key 2', 'key 1') + .hget(new Buffer('hash key 2'), 'key 1') + .hget('hash key 2', new Buffer('key 2')) + .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(4, reply.length); - assert.strictEqual("", reply[0].inspect()); + assert.strictEqual('', reply[0].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[1].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[2])); - assert.strictEqual("", reply[2].inspect()); + assert.strictEqual('', reply[2].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[3])); - assert.strictEqual("", reply[3].inspect()); + assert.strictEqual('', reply[3].inspect()); return done(err); }); }); @@ -86,20 +86,20 @@ describe("return_buffers", function () { describe('batch.hget', function () { it('returns buffers', function (done) { client.batch() - .hget("hash key 2", "key 1") - .hget(new Buffer("hash key 2"), "key 1") - .hget("hash key 2", new Buffer("key 2")) - .hget("hash key 2", "key 2") + .hget('hash key 2', 'key 1') + .hget(new Buffer('hash key 2'), 'key 1') + .hget('hash key 2', new Buffer('key 2')) + .hget('hash key 2', 'key 2') .exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(4, reply.length); - assert.strictEqual("", reply[0].inspect()); + assert.strictEqual('', reply[0].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[1].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[2])); - assert.strictEqual("", reply[2].inspect()); + assert.strictEqual('', reply[2].inspect()); assert.strictEqual(true, Buffer.isBuffer(reply[3])); - assert.strictEqual("", reply[3].inspect()); + assert.strictEqual('', reply[3].inspect()); return done(err); }); }); @@ -108,7 +108,7 @@ describe("return_buffers", function () { describe('hmget', function () { describe('first argument is a string', function () { it('handles array of strings with undefined values in transaction (repro #344)', function (done) { - client.multi().hmget("hash key 2", "key 3", "key 4").exec(function(err, reply) { + client.multi().hmget('hash key 2', 'key 3', 'key 4').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); @@ -121,39 +121,39 @@ describe("return_buffers", function () { describe('first argument is a buffer', function () { it('returns buffers for keys requested', function (done) { - client.hmget(new Buffer("hash key 2"), "key 1", "key 2", function (err, reply) { + client.hmget(new Buffer('hash key 2'), 'key 1', 'key 2', function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(2, reply.length); assert.strictEqual(true, Buffer.isBuffer(reply[0])); assert.strictEqual(true, Buffer.isBuffer(reply[1])); - assert.strictEqual("", reply[0].inspect()); - assert.strictEqual("", reply[1].inspect()); + assert.strictEqual('', reply[0].inspect()); + assert.strictEqual('', reply[1].inspect()); return done(err); }); }); - it("returns buffers for keys requested in transaction", function (done) { - client.multi().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) { + it('returns buffers for keys requested in transaction', function (done) { + client.multi().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); assert.strictEqual(true, Buffer.isBuffer(reply[0][0])); assert.strictEqual(true, Buffer.isBuffer(reply[0][1])); - assert.strictEqual("", reply[0][0].inspect()); - assert.strictEqual("", reply[0][1].inspect()); + assert.strictEqual('', reply[0][0].inspect()); + assert.strictEqual('', reply[0][1].inspect()); return done(err); }); }); - it("returns buffers for keys requested in .batch", function (done) { - client.batch().hmget(new Buffer("hash key 2"), "key 1", "key 2").exec(function (err, reply) { + it('returns buffers for keys requested in .batch', function (done) { + client.batch().hmget(new Buffer('hash key 2'), 'key 1', 'key 2').exec(function (err, reply) { assert.strictEqual(true, Array.isArray(reply)); assert.strictEqual(1, reply.length); assert.strictEqual(2, reply[0].length); assert.strictEqual(true, Buffer.isBuffer(reply[0][0])); assert.strictEqual(true, Buffer.isBuffer(reply[0][1])); - assert.strictEqual("", reply[0][0].inspect()); - assert.strictEqual("", reply[0][1].inspect()); + assert.strictEqual('', reply[0][0].inspect()); + assert.strictEqual('', reply[0][1].inspect()); return done(err); }); }); @@ -163,33 +163,33 @@ describe("return_buffers", function () { describe('hgetall', function (done) { describe('first argument is a string', function () { it('returns buffer values', function (done) { - client.hgetall("hash key 2", function (err, reply) { - assert.strictEqual("object", typeof reply); + client.hgetall('hash key 2', function (err, reply) { + assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); - assert.strictEqual("", reply["key 1"].inspect()); - assert.strictEqual("", reply["key 2"].inspect()); + assert.strictEqual('', reply['key 1'].inspect()); + assert.strictEqual('', reply['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in transaction', function (done) { - client.multi().hgetall("hash key 2").exec(function (err, reply) { + client.multi().hgetall('hash key 2').exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in .batch', function (done) { - client.batch().hgetall("hash key 2").exec(function (err, reply) { + client.batch().hgetall('hash key 2').exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); @@ -197,40 +197,40 @@ describe("return_buffers", function () { describe('first argument is a buffer', function () { it('returns buffer values', function (done) { - client.hgetall(new Buffer("hash key 2"), function (err, reply) { + client.hgetall(new Buffer('hash key 2'), function (err, reply) { assert.strictEqual(null, err); - assert.strictEqual("object", typeof reply); + assert.strictEqual('object', typeof reply); assert.strictEqual(2, Object.keys(reply).length); - assert.strictEqual(true, Buffer.isBuffer(reply["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply["key 2"])); - assert.strictEqual("", reply["key 1"].inspect()); - assert.strictEqual("", reply["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply['key 2'])); + assert.strictEqual('', reply['key 1'].inspect()); + assert.strictEqual('', reply['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in transaction', function (done) { - client.multi().hgetall(new Buffer("hash key 2")).exec(function (err, reply) { + client.multi().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"])); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2'])); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); it('returns buffer values when executed in .batch', function (done) { - client.batch().hgetall(new Buffer("hash key 2")).exec(function (err, reply) { + client.batch().hgetall(new Buffer('hash key 2')).exec(function (err, reply) { assert.strictEqual(1, reply.length); - assert.strictEqual("object", typeof reply[0]); + assert.strictEqual('object', typeof reply[0]); assert.strictEqual(2, Object.keys(reply[0]).length); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 1"])); - assert.strictEqual(true, Buffer.isBuffer(reply[0]["key 2"])); - assert.strictEqual("", reply[0]["key 1"].inspect()); - assert.strictEqual("", reply[0]["key 2"].inspect()); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 1'])); + assert.strictEqual(true, Buffer.isBuffer(reply[0]['key 2'])); + assert.strictEqual('', reply[0]['key 1'].inspect()); + assert.strictEqual('', reply[0]['key 2'].inspect()); return done(err); }); }); @@ -240,8 +240,8 @@ describe("return_buffers", function () { describe('publish/subscribe', function (done) { var pub; var sub; - var channel = "test channel"; - var message = new Buffer("test message"); + var channel = 'test channel'; + var message = new Buffer('test message'); var args = config.configureClient(parser, ip, { return_buffers: true @@ -253,7 +253,7 @@ describe("return_buffers", function () { pub = redis.createClient.apply(redis.createClient, basicArgs); sub = redis.createClient.apply(redis.createClient, args); - pub.once("connect", function () { + pub.once('connect', function () { pub.flushdb(function () { pubConnected = true; if (subConnected) { @@ -261,7 +261,7 @@ describe("return_buffers", function () { } }); }); - sub.once("connect", function () { + sub.once('connect', function () { subConnected = true; if (pubConnected) { done(); @@ -270,13 +270,13 @@ describe("return_buffers", function () { }); it('receives buffer messages', function (done) { - sub.on("subscribe", function (chnl, count) { + sub.on('subscribe', function (chnl, count) { pub.publish(channel, message); }); - sub.on("message", function (chnl, msg) { + sub.on('message', function (chnl, msg) { assert.strictEqual(true, Buffer.isBuffer(msg)); - assert.strictEqual("", msg.inspect()); + assert.strictEqual('', msg.inspect()); return done(); }); diff --git a/test/tls.spec.js b/test/tls.spec.js index 0fb051cf67..68cc02d95f 100644 --- a/test/tls.spec.js +++ b/test/tls.spec.js @@ -1,7 +1,7 @@ 'use strict'; -var assert = require("assert"); -var config = require("./lib/config"); +var assert = require('assert'); +var config = require('./lib/config'); var fs = require('fs'); var helper = require('./helper'); var path = require('path'); @@ -9,9 +9,9 @@ var redis = config.redis; var utils = require('../lib/utils'); var tls_options = { - servername: "redis.js.org", + servername: 'redis.js.org', rejectUnauthorized: true, - ca: [ String(fs.readFileSync(path.resolve(__dirname, "./conf/redis.js.org.cert"))) ] + ca: [ String(fs.readFileSync(path.resolve(__dirname, './conf/redis.js.org.cert'))) ] }; var tls_port = 6380; @@ -21,14 +21,14 @@ var skip = false; // Wait until stunnel4 is in the travis whitelist // Check: https://github.com/travis-ci/apt-package-whitelist/issues/403 // If this is merged, remove the travis env checks -describe("TLS connection tests", function () { +describe('TLS connection tests', function () { before(function (done) { // Print the warning when the tests run instead of while starting mocha if (process.platform === 'win32') { skip = true; console.warn('\nStunnel tests do not work on windows atm. If you think you can fix that, it would be warmly welcome.\n'); - } else if (process.env.TRAVIS === 'true') { + } else if (process.env.TRAVIS === 'true') { skip = true; console.warn('\nTravis does not support stunnel right now. Skipping tests.\nCheck: https://github.com/travis-ci/apt-package-whitelist/issues/403\n'); } @@ -50,8 +50,8 @@ describe("TLS connection tests", function () { client.end(true); }); - describe("on lost connection", function () { - it("emit an error after max retry timeout and do not try to reconnect afterwards", function (done) { + describe('on lost connection', function () { + it('emit an error after max retry timeout and do not try to reconnect afterwards', function (done) { if (skip) this.skip(); var connect_timeout = 500; // in ms client = redis.createClient({ @@ -61,15 +61,15 @@ describe("TLS connection tests", function () { }); var time = 0; - client.once('ready', function() { + client.once('ready', function () { helper.killConnection(client); }); - client.on("reconnecting", function (params) { + client.on('reconnecting', function (params) { time += params.delay; }); - client.on('error', function(err) { + client.on('error', function (err) { if (/Redis connection in broken state: connection timeout.*?exceeded./.test(err.message)) { setTimeout(function () { assert(time === connect_timeout); @@ -80,9 +80,9 @@ describe("TLS connection tests", function () { }); }); - describe("when not connected", function () { + describe('when not connected', function () { - it("connect with host and port provided in the options object", function (done) { + it('connect with host and port provided in the options object', function (done) { if (skip) this.skip(); client = redis.createClient({ host: 'localhost', @@ -103,7 +103,7 @@ describe("TLS connection tests", function () { it('fails to connect because the cert is not correct', function (done) { if (skip) this.skip(); var faulty_cert = utils.clone(tls_options); - faulty_cert.ca = [ String(fs.readFileSync(path.resolve(__dirname, "./conf/faulty.cert"))) ]; + faulty_cert.ca = [ String(fs.readFileSync(path.resolve(__dirname, './conf/faulty.cert'))) ]; client = redis.createClient({ host: 'localhost', connect_timeout: 1000, diff --git a/test/unify_options.spec.js b/test/unify_options.spec.js index 975ce2b53d..eb441d81a6 100644 --- a/test/unify_options.spec.js +++ b/test/unify_options.spec.js @@ -113,7 +113,7 @@ describe('createClient options', function () { it('duplicated, identical query options including options obj', function () { var text = ''; - var unhookIntercept = intercept(function(data) { + var unhookIntercept = intercept(function (data) { text += data; return ''; }); @@ -152,7 +152,7 @@ describe('createClient options', function () { } }); - it("warns on protocol other than redis in the redis url", function () { + it('warns on protocol other than redis in the redis url', function () { var text = ''; var unhookIntercept = intercept(function (data) { text += data; @@ -229,7 +229,7 @@ describe('createClient options', function () { }); describe('faulty data', function () { - it("throws on strange connection info", function () { + it('throws on strange connection info', function () { try { unifyOptions(true); throw new Error('failed'); diff --git a/test/utils.spec.js b/test/utils.spec.js index c886648d39..d77c7eb607 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -44,7 +44,7 @@ describe('utils.js', function () { describe('print helper', function () { it('callback with reply', function () { var text = ''; - var unhookIntercept = intercept(function(data) { + var unhookIntercept = intercept(function (data) { text += data; return ''; }); @@ -55,7 +55,7 @@ describe('utils.js', function () { it('callback with error', function () { var text = ''; - var unhookIntercept = intercept(function(data) { + var unhookIntercept = intercept(function (data) { text += data; return ''; });