You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
test fixup
This commit is contained in:
@@ -1,27 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('assert')
|
||||
var config = require('../lib/config')
|
||||
var helper = require('../helper')
|
||||
var redis = config.redis
|
||||
const Buffer = require('safe-buffer').Buffer
|
||||
const assert = require('assert')
|
||||
const config = require('../lib/config')
|
||||
const helper = require('../helper')
|
||||
const redis = config.redis
|
||||
|
||||
describe('The \'hgetall\' method', function () {
|
||||
helper.allTests(function (ip, args) {
|
||||
describe('using ' + ip, function () {
|
||||
var client
|
||||
describe('The \'hgetall\' method', () => {
|
||||
helper.allTests((ip, args) => {
|
||||
describe(`using ${ip}`, () => {
|
||||
let client
|
||||
|
||||
describe('regular client', function () {
|
||||
beforeEach(function (done) {
|
||||
describe('regular client', () => {
|
||||
beforeEach((done) => {
|
||||
client = redis.createClient.apply(null, args)
|
||||
client.once('ready', function () {
|
||||
client.once('ready', () => {
|
||||
client.flushdb(done)
|
||||
})
|
||||
})
|
||||
|
||||
it('handles simple keys and values', function (done) {
|
||||
it('handles simple keys and values', (done) => {
|
||||
client.hmset(['hosts', 'hasOwnProperty', '1', 'another', '23', 'home', '1234'], helper.isString('OK'))
|
||||
client.hgetall(['hosts'], function (err, obj) {
|
||||
client.hgetall(['hosts'], (err, obj) => {
|
||||
assert.strictEqual(3, Object.keys(obj).length)
|
||||
assert.strictEqual('1', obj.hasOwnProperty.toString())
|
||||
assert.strictEqual('23', obj.another.toString())
|
||||
@@ -30,39 +30,39 @@ describe('The \'hgetall\' method', function () {
|
||||
})
|
||||
})
|
||||
|
||||
it('handles fetching keys set using an object', function (done) {
|
||||
it('handles fetching keys set using an object', (done) => {
|
||||
client.batch().hmset('msgTest', { message: 'hello' }, undefined).exec()
|
||||
client.hgetall('msgTest', function (err, obj) {
|
||||
client.hgetall('msgTest', (err, obj) => {
|
||||
assert.strictEqual(1, Object.keys(obj).length)
|
||||
assert.strictEqual(obj.message, 'hello')
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
|
||||
it('handles fetching a messing key', function (done) {
|
||||
client.hgetall('missing', function (err, obj) {
|
||||
it('handles fetching a messing key', (done) => {
|
||||
client.hgetall('missing', (err, obj) => {
|
||||
assert.strictEqual(null, obj)
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('binary client', function () {
|
||||
var client
|
||||
var args = config.configureClient(ip, {
|
||||
describe('binary client', () => {
|
||||
let client
|
||||
const args = config.configureClient(ip, {
|
||||
returnBuffers: true
|
||||
})
|
||||
|
||||
beforeEach(function (done) {
|
||||
beforeEach((done) => {
|
||||
client = redis.createClient.apply(null, args)
|
||||
client.once('ready', function () {
|
||||
client.once('ready', () => {
|
||||
client.flushdb(done)
|
||||
})
|
||||
})
|
||||
|
||||
it('returns binary results', function (done) {
|
||||
it('returns binary results', (done) => {
|
||||
client.hmset(['bhosts', 'mjr', '1', 'another', '23', 'home', '1234', Buffer.from([0xAA, 0xBB, 0x00, 0xF0]), Buffer.from([0xCC, 0xDD, 0x00, 0xF0])], helper.isString('OK'))
|
||||
client.hgetall('bhosts', function (err, obj) {
|
||||
client.hgetall('bhosts', (err, obj) => {
|
||||
assert.strictEqual(4, Object.keys(obj).length)
|
||||
assert.strictEqual('1', obj.mjr.toString())
|
||||
assert.strictEqual('23', obj.another.toString())
|
||||
@@ -74,7 +74,7 @@ describe('The \'hgetall\' method', function () {
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
afterEach(() => {
|
||||
client.end(true)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user