1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00

use dockers for tests, fix some bugs

This commit is contained in:
leibale
2021-11-01 11:30:25 -04:00
parent f6f9b3dccd
commit 5cff3320d2
240 changed files with 2125 additions and 2047 deletions

View File

@@ -8,5 +8,8 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
],
"rules": {
"semi": [2, "always"]
}
}

View File

@@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x]
redis-version: [5.x, 6.0.x, 6.2.x]
redis-version: [5, 6.0, 6.2]
steps:
- uses: actions/checkout@v2.3.4
@@ -25,17 +25,11 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- name: Setup Redis
uses: shogo82148/actions-setup-redis@v1.12.0
with:
redis-version: ${{ matrix.redis-version }}
auto-start: "false"
- name: Install Packages
run: npm ci
- name: Run Tests
run: npm run test
run: npm run test -- --forbid-only --redis-version=${{ matrix.redis-version }}
- name: Generate lcov
run: ./node_modules/.bin/nyc report -r lcov

View File

@@ -1,4 +1,4 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"exclude": ["**/*.spec.ts", "lib/test-utils.ts"]
"exclude": ["**/*.spec.ts", "lib/test-utils/**/*.ts"]
}

View File

@@ -126,7 +126,7 @@ This pattern works especially well for blocking commands—such as `BLPOP` and `
```typescript
import { commandOptions } from 'redis';
const blPopPromise = client.blPop(commandOptions({ isolated: true }), 'key');
const blPopPromise = client.blPop(commandOptions({ isolated: true }), 'key', 0);
await client.lPush('key', ['1', '2']);

View File

@@ -45,7 +45,7 @@ import { createCluster } from 'redis';
Commands such as `GET`, `SET`, etc. will be routed by the first key, for instance `MGET 1 2 3` will be routed by the key `1`.
### [Server Commands][https://redis.io/commands#server]
### [Server Commands](https://redis.io/commands#server)
Admin commands such as `MEMORY STATS`, `FLUSHALL`, etc. are not attached to the cluster, and should be executed on a specific node using `.getSlot()` or `.getAllMasters()`.

View File

@@ -1,7 +1,7 @@
import LinkedList from 'yallist';
import RedisParser from 'redis-parser';
import { AbortError } from '../errors';
import { RedisCommandRawReply } from '../commands';
import { RedisCommandArguments, RedisCommandRawReply } from '../commands';
export interface QueueCommandOptions {
asap?: boolean;
@@ -10,7 +10,7 @@ export interface QueueCommandOptions {
}
interface CommandWaitingToBeSent extends CommandWaitingForReply {
args: Array<string | Buffer>;
args: RedisCommandArguments;
chainId?: symbol;
abort?: {
signal: AbortSignal;
@@ -107,7 +107,7 @@ export default class RedisCommandsQueue {
this.#maxLength = maxLength;
}
addCommand<T = RedisCommandRawReply>(args: Array<string | Buffer>, options?: QueueCommandOptions, bufferMode?: boolean): Promise<T> {
addCommand<T = RedisCommandRawReply>(args: RedisCommandArguments, options?: QueueCommandOptions, bufferMode?: boolean): Promise<T> {
if (this.#pubSubState.subscribing || this.#pubSubState.subscribed) {
return Promise.reject(new Error('Cannot send commands in PubSub mode'));
} else if (this.#maxLength && this.#waitingToBeSent.length + this.#waitingForReply.length >= this.#maxLength) {
@@ -247,7 +247,7 @@ export default class RedisCommandsQueue {
]);
}
getCommandToSend(): Array<string | Buffer> | undefined {
getCommandToSend(): RedisCommandArguments | undefined {
const toSend = this.#waitingToBeSent.shift();
if (toSend) {

View File

@@ -1,11 +1,12 @@
import { strict as assert, AssertionError } from 'assert';
import { once } from 'events';
import { itWithClient, TEST_REDIS_SERVERS, TestRedisServers, waitTillBeenCalled, isRedisVersionGreaterThan } from '../test-utils';
import RedisClient from '.';
import { AbortError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, WatchError } from '../errors';
import { strict as assert } from 'assert';
import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
import RedisClient, { RedisClientType } from '.';
import { RedisClientMultiCommandType } from './multi-command';
import { RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisScripts } from '../commands';
import { AbortError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors';
import { defineScript } from '../lua-script';
import { spy } from 'sinon';
import { RedisNetSocketOptions } from '../client/socket';
import { once } from 'events';
export const SQUARE_SCRIPT = defineScript({
NUMBER_OF_KEYS: 0,
@@ -75,43 +76,21 @@ describe('Client', () => {
}
);
});
it('createClient with url', async () => {
const client = RedisClient.create({
url: `redis://localhost:${(TEST_REDIS_SERVERS[TestRedisServers.OPEN].socket as RedisNetSocketOptions)!.port!.toString()}/1`
});
await client.connect();
try {
assert.equal(
await client.ping(),
'PONG'
);
} finally {
await client.disconnect();
}
})
});
describe('authentication', () => {
itWithClient(TestRedisServers.PASSWORD, 'Client should be authenticated', async client => {
testUtils.testWithClient('Client should be authenticated', async client => {
assert.equal(
await client.ping(),
'PONG'
);
});
it('should not retry connecting if failed due to wrong auth', async () => {
const client = RedisClient.create({
...TEST_REDIS_SERVERS[TestRedisServers.PASSWORD],
password: 'wrongpassword'
});
}, GLOBAL.SERVERS.PASSWORD);
testUtils.testWithClient('should not retry connecting if failed due to wrong auth', async client => {
let message;
if (isRedisVersionGreaterThan([6, 2])) {
if (testUtils.isVersionGreaterThan([6, 2])) {
message = 'WRONGPASS invalid username-password pair or user is disabled.';
} else if (isRedisVersionGreaterThan([6])) {
} else if (testUtils.isVersionGreaterThan([6])) {
message = 'WRONGPASS invalid username-password pair';
} else {
message = 'ERR invalid password';
@@ -123,173 +102,216 @@ describe('Client', () => {
);
assert.equal(client.isOpen, false);
}, {
...GLOBAL.SERVERS.PASSWORD,
clientOptions: {
password: 'wrongpassword'
},
disableClientSetup: true
});
itWithClient(TestRedisServers.PASSWORD, 'should execute AUTH before SELECT', async client => {
testUtils.testWithClient('should execute AUTH before SELECT', async client => {
assert.equal(
(await client.clientInfo()).db,
2
);
}, {
minimumRedisVersion: [6, 2],
...GLOBAL.SERVERS.PASSWORD,
clientOptions: {
...GLOBAL.SERVERS.PASSWORD.clientOptions,
database: 2
}
},
minimumDockerVersion: [6, 2]
});
});
describe('legacyMode', () => {
const client = RedisClient.create({
...TEST_REDIS_SERVERS[TestRedisServers.OPEN],
scripts: {
square: SQUARE_SCRIPT
},
function sendCommandAsync<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>, args: RedisCommandArguments): Promise<RedisCommandRawReply> {
return new Promise((resolve, reject) => {
(client as any).sendCommand(args, (err: Error | undefined, reply: RedisCommandRawReply) => {
if (err) return reject(err);
resolve(reply);
});
});
}
testUtils.testWithClient('client.sendCommand should call the callback', async client => {
assert.equal(
await sendCommandAsync(client, ['PING']),
'PONG'
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
});
before(() => client.connect());
afterEach(() => client.v4.flushAll());
after(() => client.disconnect());
it('client.sendCommand should call the callback', done => {
(client as any).sendCommand('PING', (err?: Error, reply?: string) => {
if (err) {
return done(err);
}
try {
assert.equal(reply, 'PONG');
done();
} catch (err) {
done(err);
}
});
});
it('client.sendCommand should work without callback', async () => {
(client as any).sendCommand('PING');
testUtils.testWithClient('client.sendCommand should work without callback', async client => {
client.sendCommand(['PING']);
await client.v4.ping(); // make sure the first command was replied
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
it('client.v4.sendCommand should return a promise', async () => {
testUtils.testWithClient('client.v4.sendCommand should return a promise', async client => {
assert.equal(
await client.v4.sendCommand(['PING']),
'PONG'
);
});
it('client.{command} should accept vardict arguments', done => {
(client as any).set('a', 'b', (err?: Error, reply?: string) => {
if (err) {
return done(err);
}
try {
assert.equal(reply, 'OK');
done();
} catch (err) {
done(err);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
});
it('client.{command} should accept arguments array', done => {
(client as any).set(['a', 'b'], (err?: Error, reply?: string) => {
if (err) {
return done(err);
function setAsync<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>, ...args: Array<string | Buffer | RedisCommandArguments>): Promise<RedisCommandRawReply> {
return new Promise((resolve, reject) => {
(client as any).set(...args, (err: Error | undefined, reply: RedisCommandRawReply) => {
if (err) return reject(err);
resolve(reply);
});
});
}
try {
assert.equal(reply, 'OK');
done();
} catch (err) {
done(err);
testUtils.testWithClient('client.{command} should accept vardict arguments', async client => {
assert.equal(
await setAsync(client, 'a', 'b'),
'OK'
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
});
it('client.{command} should accept mix of strings and array of strings', done => {
(client as any).set(['a'], 'b', ['XX'], (err?: Error, reply?: string) => {
if (err) {
return done(err);
}
try {
assert.equal(reply, null);
done();
} catch (err) {
done(err);
testUtils.testWithClient('client.{command} should accept arguments array', async client => {
assert.equal(
await setAsync(client, ['a', 'b']),
'OK'
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
});
it('client.multi.ping.exec should call the callback', done => {
(client as any).multi()
.ping()
.exec((err?: Error, reply?: string) => {
if (err) {
return done(err);
}
try {
assert.deepEqual(reply, ['PONG']);
done();
} catch (err) {
done(err);
testUtils.testWithClient('client.{command} should accept mix of strings and array of strings', async client => {
assert.equal(
await setAsync(client, ['a'], 'b', ['XX']),
null
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
function multiExecAsync<M extends RedisModules, S extends RedisScripts>(multi: RedisClientMultiCommandType<M, S>): Promise<Array<RedisCommandRawReply>> {
return new Promise((resolve, reject) => {
(multi as any).exec((err: Error | undefined, replies: Array<RedisCommandRawReply>) => {
if (err) return reject(err);
resolve(replies);
});
});
}
testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => {
assert.deepEqual(
await multiExecAsync(
client.multi().ping()
),
['PONG']
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
it('client.multi.ping.exec should work without callback', async () => {
(client as any).multi()
testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => {
client.multi()
.ping()
.exec();
await client.v4.ping(); // make sure the first command was replied
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
it('client.multi.ping.v4.ping.v4.exec should return a promise', async () => {
testUtils.testWithClient('client.multi.ping.v4.ping.v4.exec should return a promise', async client => {
assert.deepEqual(
await ((client as any).multi()
await client.multi()
.ping()
.v4.ping()
.v4.exec()),
.v4.exec(),
['PONG', 'PONG']
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true
}
});
it('client.{script} should return a promise', async () => {
assert.equal(await client.square(2), 4);
testUtils.testWithClient('client.{script} should return a promise', async client => {
assert.equal(
await client.square(2),
4
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
legacyMode: true,
scripts: {
square: SQUARE_SCRIPT
}
}
});
});
describe('events', () => {
it('connect, ready, end', async () => {
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
testUtils.testWithClient('connect, ready, end', async client => {
await Promise.all([
client.connect(),
once(client, 'connect'),
once(client, 'ready')
once(client, 'ready'),
client.connect()
]);
await Promise.all([
client.disconnect(),
once(client, 'end')
once(client, 'end'),
client.disconnect()
]);
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true
});
});
describe('sendCommand', () => {
itWithClient(TestRedisServers.OPEN, 'PING', async client => {
testUtils.testWithClient('PING', async client => {
assert.equal(await client.sendCommand(['PING']), 'PONG');
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'bufferMode', async client => {
testUtils.testWithClient('bufferMode', async client => {
assert.deepEqual(
await client.sendCommand(['PING'], undefined, true),
Buffer.from('PONG')
);
});
}, GLOBAL.SERVERS.OPEN);
describe('AbortController', () => {
before(function () {
@@ -298,13 +320,13 @@ describe('Client', () => {
}
});
itWithClient(TestRedisServers.OPEN, 'success', async client => {
testUtils.testWithClient('success', async client => {
await client.sendCommand(['PING'], {
signal: new AbortController().signal
});
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'AbortError', client => {
testUtils.testWithClient('AbortError', client => {
const controller = new AbortController();
controller.abort();
@@ -314,12 +336,12 @@ describe('Client', () => {
}),
AbortError
);
});
}, GLOBAL.SERVERS.OPEN);
});
});
describe('multi', () => {
itWithClient(TestRedisServers.OPEN, 'simple', async client => {
testUtils.testWithClient('simple', async client => {
assert.deepEqual(
await client.multi()
.ping()
@@ -328,23 +350,19 @@ describe('Client', () => {
.exec(),
['PONG', 'OK', 'value']
);
});
itWithClient(TestRedisServers.OPEN, 'should reject the whole chain on error', client => {
client.on('error', () => {
// ignore errors
});
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should reject the whole chain on error', client => {
return assert.rejects(
client.multi()
.ping()
.addCommand(['DEBUG', 'RESTART'])
.addCommand(['INVALID COMMAND'])
.ping()
.exec()
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'with script', async client => {
testUtils.testWithClient('with script', async client => {
assert.deepEqual(
await client.multi()
.square(2)
@@ -352,6 +370,7 @@ describe('Client', () => {
[4]
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
scripts: {
square: SQUARE_SCRIPT
@@ -359,7 +378,7 @@ describe('Client', () => {
}
});
itWithClient(TestRedisServers.OPEN, 'WatchError', async client => {
testUtils.testWithClient('WatchError', async client => {
await client.watch('key');
await client.set(
@@ -376,24 +395,25 @@ describe('Client', () => {
.exec(),
WatchError
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'execAsPipeline', async client => {
testUtils.testWithClient('execAsPipeline', async client => {
assert.deepEqual(
await client.multi()
.ping()
.exec(true),
['PONG']
);
});
}, GLOBAL.SERVERS.OPEN);
});
itWithClient(TestRedisServers.OPEN, 'scripts', async client => {
testUtils.testWithClient('scripts', async client => {
assert.equal(
await client.square(2),
4
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
scripts: {
square: SQUARE_SCRIPT
@@ -401,12 +421,13 @@ describe('Client', () => {
}
});
itWithClient(TestRedisServers.OPEN, 'modules', async client => {
testUtils.testWithClient('modules', async client => {
assert.equal(
await client.module.echo('message'),
'message'
);
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
modules: {
module: {
@@ -423,7 +444,7 @@ describe('Client', () => {
}
});
itWithClient(TestRedisServers.OPEN, 'executeIsolated', async client => {
testUtils.testWithClient('executeIsolated', async client => {
await client.sendCommand(['CLIENT', 'SETNAME', 'client']);
assert.equal(
@@ -432,35 +453,35 @@ describe('Client', () => {
),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'should reconnect after DEBUG RESTART', async client => {
client.on('error', () => {
// ignore errors
});
async function killClient<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>): Promise<void> {
const onceErrorPromise = once(client, 'error');
await client.sendCommand(['QUIT']);
await Promise.all([
onceErrorPromise,
assert.rejects(client.ping(), SocketClosedUnexpectedlyError)
]);
}
await client.sendCommand(['CLIENT', 'SETNAME', 'client']);
await assert.rejects(client.sendCommand(['DEBUG', 'RESTART']));
assert.ok(await client.sendCommand(['CLIENT', 'GETNAME']) === null);
});
itWithClient(TestRedisServers.OPEN, 'should SELECT db after reconnection', async client => {
client.on('error', () => {
// ignore errors
});
testUtils.testWithClient('should reconnect when socket disconnects', async client => {
await killClient(client);
await assert.doesNotReject(client.ping());
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should remember selected db', async client => {
await client.select(1);
await assert.rejects(client.sendCommand(['DEBUG', 'RESTART']));
await killClient(client);
assert.equal(
(await client.clientInfo()).db,
1
);
}, {
// because of CLIENT INFO
minimumRedisVersion: [6, 2]
...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2] // CLIENT INFO
});
itWithClient(TestRedisServers.OPEN, 'scanIterator', async client => {
testUtils.testWithClient('scanIterator', async client => {
const promises = [],
keys = new Set();
for (let i = 0; i < 100; i++) {
@@ -477,9 +498,9 @@ describe('Client', () => {
}
assert.deepEqual(keys, results);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'hScanIterator', async client => {
testUtils.testWithClient('hScanIterator', async client => {
const hash: Record<string, string> = {};
for (let i = 0; i < 100; i++) {
hash[i.toString()] = i.toString();
@@ -493,9 +514,9 @@ describe('Client', () => {
}
assert.deepEqual(hash, results);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'sScanIterator', async client => {
testUtils.testWithClient('sScanIterator', async client => {
const members = new Set<string>();
for (let i = 0; i < 100; i++) {
members.add(i.toString());
@@ -509,9 +530,9 @@ describe('Client', () => {
}
assert.deepEqual(members, results);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'zScanIterator', async client => {
testUtils.testWithClient('zScanIterator', async client => {
const members = [];
for (let i = 0; i < 100; i++) {
members.push({
@@ -537,9 +558,9 @@ describe('Client', () => {
[...map.entries()].sort(sort),
members.map<MemberTuple>(member => [member.value, member.score]).sort(sort)
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'PubSub', async publisher => {
testUtils.testWithClient('PubSub', async publisher => {
const subscriber = publisher.duplicate();
await subscriber.connect();
@@ -602,17 +623,9 @@ describe('Client', () => {
} finally {
await subscriber.disconnect();
}
});
}, GLOBAL.SERVERS.OPEN);
it('ConnectionTimeoutError', async () => {
const client = RedisClient.create({
socket: {
...TEST_REDIS_SERVERS[TestRedisServers.OPEN],
connectTimeout: 1
}
});
try {
testUtils.testWithClient('ConnectionTimeoutError', async client => {
const promise = assert.rejects(client.connect(), ConnectionTimeoutError),
start = process.hrtime.bigint();
@@ -621,21 +634,19 @@ describe('Client', () => {
}
await promise;
} catch (err) {
if (err instanceof AssertionError) {
await client.disconnect();
}
throw err;
}, {
...GLOBAL.SERVERS.OPEN,
clientOptions: {
socket: {
connectTimeout: 1
}
},
disableClientSetup: true
});
it('client.quit', async () => {
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
testUtils.testWithClient('client.quit', async client => {
await client.connect();
try {
const pingPromise = client.ping(),
quitPromise = client.quit();
assert.equal(client.isOpen, false);
@@ -647,19 +658,14 @@ describe('Client', () => {
]);
assert.equal(ping, 'PONG');
} finally {
if (client.isOpen) {
await client.disconnect();
}
}
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true
});
it('client.disconnect', async () => {
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
testUtils.testWithClient('client.disconnect', async client => {
await client.connect();
try {
const pingPromise = client.ping(),
disconnectPromise = client.disconnect();
assert.equal(client.isOpen, false);
@@ -668,10 +674,8 @@ describe('Client', () => {
assert.doesNotReject(disconnectPromise),
assert.rejects(client.ping(), ClientClosedError)
]);
} finally {
if (client.isOpen) {
await client.disconnect();
}
}
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true
});
});

View File

@@ -9,7 +9,7 @@ import { CommandOptions, commandOptions, isCommandOptions } from '../command-opt
import { ScanOptions, ZMember } from '../commands/generic-transformers';
import { ScanCommandOptions } from '../commands/SCAN';
import { HScanTuple } from '../commands/HSCAN';
import { encodeCommand, extendWithCommands, extendWithModulesAndScripts, transformCommandArguments, transformCommandReply } from '../commander';
import { extendWithCommands, extendWithModulesAndScripts, transformCommandArguments, transformCommandReply } from '../commander';
import { Pool, Options as PoolOptions, createPool } from 'generic-pool';
import { ClientClosedError, DisconnectsClientError } from '../errors';
import { URL } from 'url';
@@ -217,7 +217,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
}
if (promises.length) {
this.#tick();
this.#tick(true);
await Promise.all(promises);
}
};
@@ -435,8 +435,8 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
quit = this.QUIT;
#tick(): void {
if (!this.#socket.isSocketExists || this.#socket.writableNeedDrain) {
#tick(force = false): void {
if (this.#socket.writableNeedDrain || (!force && !this.#socket.isReady)) {
return;
}
@@ -446,9 +446,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
const args = this.#queue.getCommandToSend();
if (args === undefined) break;
for (const toWrite of encodeCommand(args)) {
this.#socket.write(toWrite);
}
this.#socket.writeCommand(args);
}
}
@@ -485,7 +483,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
for (const key of reply.keys) {
yield key;
}
} while (cursor !== 0)
} while (cursor !== 0);
}
async* hScanIterator(key: string, options?: ScanOptions): AsyncIterable<HScanTuple> {
@@ -496,7 +494,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
for (const tuple of reply.tuples) {
yield tuple;
}
} while (cursor !== 0)
} while (cursor !== 0);
}
async* sScanIterator(key: string, options?: ScanOptions): AsyncIterable<string> {
@@ -507,7 +505,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
for (const member of reply.members) {
yield member;
}
} while (cursor !== 0)
} while (cursor !== 0);
}
async* zScanIterator(key: string, options?: ScanOptions): AsyncIterable<ZMember> {
@@ -518,15 +516,13 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
for (const member of reply.members) {
yield member;
}
} while (cursor !== 0)
} while (cursor !== 0);
}
async disconnect(): Promise<void> {
this.#queue.flushAll(new DisconnectsClientError());
await Promise.all([
this.#socket.disconnect(),
this.#destroyIsolationPool()
]);
this.#socket.disconnect();
await this.#destroyIsolationPool();
}
async #destroyIsolationPool(): Promise<void> {

View File

@@ -33,6 +33,6 @@ describe('Socket', () => {
return assert.rejects(socket.connect(), {
message: '50'
});
})
});
});
});

View File

@@ -1,7 +1,9 @@
import EventEmitter from 'events';
import net from 'net';
import tls from 'tls';
import { ConnectionTimeoutError, ClientClosedError } from '../errors';
import { encodeCommand } from '../commander';
import { RedisCommandArguments } from '../commands';
import { ConnectionTimeoutError, ClientClosedError, SocketClosedUnexpectedlyError } from '../errors';
import { promiseTimeout } from '../utils';
export interface RedisSocketCommonOptions {
@@ -72,8 +74,10 @@ export default class RedisSocket extends EventEmitter {
return this.#isOpen;
}
get isSocketExists(): boolean {
return !!this.#socket;
#isReady = false;
get isReady(): boolean {
return this.#isReady;
}
// `writable.writableNeedDrain` was added in v15.2.0 and therefore can't be used
@@ -93,33 +97,39 @@ export default class RedisSocket extends EventEmitter {
async connect(): Promise<void> {
if (this.#isOpen) {
throw new Error('Socket is connection/connecting');
throw new Error('Socket already opened');
}
this.#isOpen = true;
try {
await this.#connect();
} catch (err) {
this.#isOpen = false;
throw err;
}
return this.#connect();
}
async #connect(hadError?: boolean): Promise<void> {
this.#isOpen = true;
this.#socket = await this.#retryConnection(0, hadError);
this.#writableNeedDrain = false;
if (!this.#isOpen) {
this.disconnect();
return;
}
this.emit('connect');
if (this.#initiator) {
try {
await this.#initiator();
} catch (err) {
this.#socket.end();
this.#socket.destroy();
this.#socket = undefined;
this.#isOpen = false;
throw err;
}
if (!this.#isOpen) return;
}
this.#isReady = true;
this.emit('ready');
}
@@ -168,7 +178,7 @@ export default class RedisSocket extends EventEmitter {
.once('error', (err: Error) => this.#onSocketError(err))
.once('close', hadError => {
if (!hadError && this.#isOpen) {
this.#onSocketError(new Error('Socket closed unexpectedly'));
this.#onSocketError(new SocketClosedUnexpectedlyError());
}
})
.on('drain', () => {
@@ -197,33 +207,32 @@ export default class RedisSocket extends EventEmitter {
}
#onSocketError(err: Error): void {
this.#socket = undefined;
this.#isReady = false;
this.emit('error', err);
this.#connect(true)
.catch(err => this.emit('error', err));
this.#connect(true).catch(() => {
// the error was already emitted, silently ignore it
});
}
write(toWrite: string | Buffer): boolean {
writeCommand(args: RedisCommandArguments): void {
if (!this.#socket) {
throw new ClientClosedError();
}
const wasFullyWritten = this.#socket.write(toWrite);
this.#writableNeedDrain = !wasFullyWritten;
return wasFullyWritten;
for (const toWrite of encodeCommand(args)) {
this.#writableNeedDrain = !this.#socket.write(toWrite);
}
}
async disconnect(ignoreIsOpen = false): Promise<void> {
if ((!ignoreIsOpen && !this.#isOpen) || !this.#socket) {
disconnect(): void {
if (!this.#socket) {
throw new ClientClosedError();
} else {
this.#isOpen = false;
this.#isOpen = this.#isReady = false;
}
this.#socket.end();
this.#socket.removeAllListeners('data');
await EventEmitter.once(this.#socket, 'end');
this.#socket.destroy();
this.#socket = undefined;
this.emit('end');
}
@@ -234,14 +243,8 @@ export default class RedisSocket extends EventEmitter {
}
this.#isOpen = false;
try {
await fn();
await this.disconnect(true);
} catch (err) {
this.#isOpen = true;
throw err;
}
this.disconnect();
}
#isCorked = false;

View File

@@ -1,17 +1,11 @@
import { strict as assert } from 'assert';
import RedisCluster from '.';
import { defineScript } from '../lua-script';
import { itWithCluster, itWithDedicatedCluster, TestRedisClusters, TEST_REDIS_CLUSTERES } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import calculateSlot from 'cluster-key-slot';
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT';
import { SQUARE_SCRIPT } from '../client/index.spec';
describe('Cluster', () => {
it('sendCommand', async () => {
const cluster = RedisCluster.create({
...TEST_REDIS_CLUSTERES[TestRedisClusters.OPEN],
useReplicas: true
});
testUtils.testWithCluster('sendCommand', async cluster => {
await cluster.connect();
try {
@@ -26,9 +20,9 @@ describe('Cluster', () => {
} finally {
await cluster.disconnect();
}
});
}, GLOBAL.CLUSTERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'multi', async cluster => {
testUtils.testWithCluster('multi', async cluster => {
const key = 'key';
assert.deepEqual(
await cluster.multi()
@@ -37,40 +31,23 @@ describe('Cluster', () => {
.exec(),
['OK', 'value']
);
});
}, GLOBAL.CLUSTERS.OPEN);
it('scripts', async () => {
const cluster = RedisCluster.create({
...TEST_REDIS_CLUSTERES[TestRedisClusters.OPEN],
scripts: {
add: defineScript({
NUMBER_OF_KEYS: 0,
SCRIPT: 'return ARGV[1] + 1;',
transformArguments(number: number): Array<string> {
assert.equal(number, 1);
return [number.toString()];
},
transformReply(reply: number): number {
assert.equal(reply, 2);
return reply;
}
})
}
});
await cluster.connect();
try {
testUtils.testWithCluster('scripts', async cluster => {
assert.equal(
await cluster.add(1),
2
await cluster.square(2),
4
);
} finally {
await cluster.disconnect();
}, {
...GLOBAL.CLUSTERS.OPEN,
clusterConfiguration: {
scripts: {
square: SQUARE_SCRIPT
}
}
});
itWithDedicatedCluster('should handle live resharding', async cluster => {
testUtils.testWithCluster('should handle live resharding', async cluster => {
const key = 'key',
value = 'value';
await cluster.set(key, value);
@@ -110,5 +87,7 @@ describe('Cluster', () => {
await cluster.get(key),
value
);
}, {
serverArguments: []
});
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_CAT';
describe('ACL CAT', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('simple', () => {

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion, itWithClient, TestRedisServers } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ACL_DELUSER';
describe('ACL DELUSER', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('string', () => {
@@ -21,10 +21,10 @@ describe('ACL DELUSER', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.aclDelUser', async client => {
testUtils.testWithClient('client.aclDelUser', async client => {
assert.equal(
await client.aclDelUser('dosenotexists'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_GENPASS';
describe('ACL GENPASS', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('simple', () => {

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion, isRedisVersionGreaterThan, itWithClient, TestRedisServers } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ACL_GETUSER';
describe('ACL GETUSER', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,14 +12,14 @@ describe('ACL GETUSER', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.aclGetUser', async client => {
testUtils.testWithClient('client.aclGetUser', async client => {
assert.deepEqual(
await client.aclGetUser('default'),
{
passwords: [],
commands: '+@all',
keys: ['*'],
...(isRedisVersionGreaterThan([6, 2]) ? {
...(testUtils.isVersionGreaterThan([6, 2]) ? {
flags: ['on', 'allkeys', 'allchannels', 'allcommands', 'nopass'],
channels: ['*']
} : {
@@ -28,5 +28,5 @@ describe('ACL GETUSER', () => {
})
}
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_LIST';
describe('ACL LIST', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_SAVE';
describe('ACL SAVE', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments, transformReply } from './ACL_LOG';
describe('ACL LOG', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('simple', () => {

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_LOG_RESET';
describe('ACL LOG RESET', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_LOAD';
describe('ACL LOAD', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_SETUSER';
describe('ACL SETUSER', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('string', () => {

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_USERS';
describe('ACL USERS', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils from '../test-utils';
import { transformArguments } from './ACL_WHOAMI';
describe('ACL WHOAMI', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
it('transformArguments', () => {
assert.deepEqual(

View File

@@ -1,7 +1,7 @@
import { strict as assert } from 'assert';
import { transformArguments } from './APPEND';
describe('AUTH', () => {
describe('APPEND', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'value'),

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BITCOUNT';
describe('BITCOUNT', () => {
@@ -22,10 +22,10 @@ describe('BITCOUNT', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.bitCount', async client => {
testUtils.testWithClient('client.bitCount', async client => {
assert.equal(
await client.bitCount('key'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BITFIELD';
describe('BITFIELD', () => {
@@ -33,10 +33,10 @@ describe('BITFIELD', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.bitField', async client => {
testUtils.testWithClient('client.bitField', async client => {
assert.deepEqual(
await client.bitField('key', []),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BITOP';
describe('BITOP', () => {
@@ -19,17 +19,17 @@ describe('BITOP', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.bitOp', async client => {
testUtils.testWithClient('client.bitOp', async client => {
assert.equal(
await client.bitOp('AND', 'destKey', 'key'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.bitOp', async cluster => {
testUtils.testWithCluster('cluster.bitOp', async cluster => {
assert.equal(
await cluster.bitOp('AND', '{tag}destKey', '{tag}key'),
0
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BITPOS';
describe('BITPOS', () => {
@@ -26,17 +26,17 @@ describe('BITPOS', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.bitPos', async client => {
testUtils.testWithClient('client.bitPos', async client => {
assert.equal(
await client.bitPos('key', 1, 1),
-1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.bitPos', async cluster => {
testUtils.testWithCluster('cluster.bitPos', async cluster => {
assert.equal(
await cluster.bitPos('key', 1, 1),
-1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,10 +1,10 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BLMOVE';
import { commandOptions } from '../../index';
describe('BLMOVE', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -13,7 +13,7 @@ describe('BLMOVE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.blMove', async client => {
testUtils.testWithClient('client.blMove', async client => {
const [blMoveReply] = await Promise.all([
client.blMove(commandOptions({
isolated: true
@@ -25,9 +25,9 @@ describe('BLMOVE', () => {
blMoveReply,
'element'
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.blMove', async cluster => {
testUtils.testWithCluster('cluster.blMove', async cluster => {
const [blMoveReply] = await Promise.all([
cluster.blMove(commandOptions({
isolated: true
@@ -39,5 +39,5 @@ describe('BLMOVE', () => {
blMoveReply,
'element'
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './BLPOP';
import { commandOptions } from '../../index';
@@ -39,7 +39,7 @@ describe('BLPOP', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.blPop', async client => {
testUtils.testWithClient('client.blPop', async client => {
const [ blPopReply ] = await Promise.all([
client.blPop(
commandOptions({ isolated: true }),
@@ -56,9 +56,9 @@ describe('BLPOP', () => {
element: 'element'
}
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.blPop', async cluster => {
testUtils.testWithCluster('cluster.blPop', async cluster => {
const [ blPopReply ] = await Promise.all([
cluster.blPop(
commandOptions({ isolated: true }),
@@ -75,5 +75,5 @@ describe('BLPOP', () => {
element: 'element'
}
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './BRPOP';
import { commandOptions } from '../../index';
@@ -39,7 +39,7 @@ describe('BRPOP', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.brPop', async client => {
testUtils.testWithClient('client.brPop', async client => {
const [ brPopReply ] = await Promise.all([
client.brPop(
commandOptions({ isolated: true }),
@@ -56,9 +56,9 @@ describe('BRPOP', () => {
element: 'element'
}
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.brPop', async cluster => {
testUtils.testWithCluster('cluster.brPop', async cluster => {
const [ brPopReply ] = await Promise.all([
cluster.brPop(
commandOptions({ isolated: true }),
@@ -75,5 +75,5 @@ describe('BRPOP', () => {
element: 'element'
}
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BRPOPLPUSH';
import { commandOptions } from '../../index';
@@ -11,7 +11,7 @@ describe('BRPOPLPUSH', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.brPopLPush', async client => {
testUtils.testWithClient('client.brPopLPush', async client => {
const [ popReply ] = await Promise.all([
client.brPopLPush(
commandOptions({ isolated: true }),
@@ -26,9 +26,9 @@ describe('BRPOPLPUSH', () => {
popReply,
'element'
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.brPopLPush', async cluster => {
testUtils.testWithCluster('cluster.brPopLPush', async cluster => {
const [ popReply ] = await Promise.all([
cluster.brPopLPush(
commandOptions({ isolated: true }),
@@ -43,5 +43,5 @@ describe('BRPOPLPUSH', () => {
popReply,
'element'
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './BZPOPMAX';
import { commandOptions } from '../../index';
@@ -40,7 +40,7 @@ describe('BZPOPMAX', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.bzPopMax', async client => {
testUtils.testWithClient('client.bzPopMax', async client => {
const [ bzPopMaxReply ] = await Promise.all([
client.bzPopMax(
commandOptions({ isolated: true }),
@@ -61,5 +61,5 @@ describe('BZPOPMAX', () => {
score: 1
}
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './BZPOPMIN';
import { commandOptions } from '../../index';
@@ -40,7 +40,7 @@ describe('BZPOPMIN', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.bzPopMin', async client => {
testUtils.testWithClient('client.bzPopMin', async client => {
const [ bzPopMinReply ] = await Promise.all([
client.bzPopMin(
commandOptions({ isolated: true }),
@@ -61,5 +61,5 @@ describe('BZPOPMIN', () => {
score: 1
}
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './CLIENT_ID';
describe('CLIENT ID', () => {
@@ -10,10 +10,10 @@ describe('CLIENT ID', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.clientId', async client => {
testUtils.testWithClient('client.clientId', async client => {
assert.equal(
typeof (await client.clientId()),
'number'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -71,6 +71,6 @@ describe('CLUSTER SLOTS', () => {
id: '58e6e48d41228013e5d9c1c37c5060693925e97e'
}]
}]
)
);
});
});

View File

@@ -1,7 +1,7 @@
import { strict as assert } from 'assert';
import { itWithClient, TestRedisServers } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND';
import { CommandCategories, CommandFlags } from './generic-transformers';
import { assertPingCommand } from './COMMAND_INFO.spec';
describe('COMMAND', () => {
it('transformArguments', () => {
@@ -11,20 +11,7 @@ describe('COMMAND', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.command', async client => {
assert.deepEqual(
(await client.command()).find(command => command.name === 'ping'),
{
name: 'ping',
arity: -1,
flags: new Set([CommandFlags.STALE, CommandFlags.FAST]),
firstKeyIndex: 0,
lastKeyIndex: 0,
step: 0,
categories: new Set([CommandCategories.FAST, CommandCategories.CONNECTION])
}
);
}, {
minimumRedisVersion: [6]
});
testUtils.testWithClient('client.command', async client => {
assertPingCommand((await client.command()).find(command => command.name === 'ping'));
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_COUNT';
describe('COMMAND COUNT', () => {
@@ -10,10 +10,10 @@ describe('COMMAND COUNT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.commandCount', async client => {
testUtils.testWithClient('client.commandCount', async client => {
assert.equal(
typeof await client.commandCount(),
'number'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_GETKEYS';
describe('COMMAND GETKEYS', () => {
@@ -10,10 +10,10 @@ describe('COMMAND GETKEYS', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.commandGetKeys', async client => {
testUtils.testWithClient('client.commandGetKeys', async client => {
assert.deepEqual(
await client.commandGetKeys(['GET', 'key']),
['key']
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,7 +1,26 @@
import { strict as assert } from 'assert';
import { itWithClient, TestRedisServers } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './COMMAND_INFO';
import { CommandCategories, CommandFlags } from './generic-transformers';
import { CommandCategories, CommandFlags, CommandReply } from './generic-transformers';
export function assertPingCommand(commandInfo: CommandReply | null | undefined): void {
assert.deepEqual(
commandInfo,
{
name: 'ping',
arity: -1,
flags: new Set([CommandFlags.STALE, CommandFlags.FAST]),
firstKeyIndex: 0,
lastKeyIndex: 0,
step: 0,
categories: new Set(
testUtils.isVersionGreaterThan([6]) ?
[CommandCategories.FAST, CommandCategories.CONNECTION] :
[]
)
}
);
}
describe('COMMAND INFO', () => {
it('transformArguments', () => {
@@ -11,20 +30,7 @@ describe('COMMAND INFO', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.commandInfo', async client => {
assert.deepEqual(
await client.commandInfo(['PING']),
[{
name: 'ping',
arity: -1,
flags: new Set([CommandFlags.STALE, CommandFlags.FAST]),
firstKeyIndex: 0,
lastKeyIndex: 0,
step: 0,
categories: new Set([CommandCategories.FAST, CommandCategories.CONNECTION])
}]
);
}, {
minimumRedisVersion: [6]
});
testUtils.testWithClient('client.commandInfo', async client => {
assertPingCommand((await client.commandInfo(['PING']))[0]);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './COPY';
describe('COPY', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('simple', () => {
@@ -58,10 +58,10 @@ describe('COPY', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.copy', async client => {
testUtils.testWithClient('client.copy', async client => {
assert.equal(
await client.copy('source', 'destination'),
false
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DBSIZE';
describe('DBSIZE', () => {
@@ -10,10 +10,10 @@ describe('DBSIZE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.dbSize', async client => {
testUtils.testWithClient('client.dbSize', async client => {
assert.equal(
await client.dbSize(),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DECR';
describe('DECR', () => {
@@ -10,10 +10,10 @@ describe('DECR', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.decr', async client => {
testUtils.testWithClient('client.decr', async client => {
assert.equal(
await client.decr('key'),
-1
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DECRBY';
describe('DECRBY', () => {
@@ -10,10 +10,10 @@ describe('DECRBY', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.decrBy', async client => {
testUtils.testWithClient('client.decrBy', async client => {
assert.equal(
await client.decrBy('key', 2),
-2
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DEL';
describe('DEL', () => {
@@ -19,10 +19,10 @@ describe('DEL', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.del', async client => {
testUtils.testWithClient('client.del', async client => {
assert.equal(
await client.del('key'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
describe('DUMP', () => {
itWithClient(TestRedisServers.OPEN, 'client.dump', async client => {
testUtils.testWithClient('client.dump', async client => {
assert.equal(
await client.dump('key'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ECHO';
describe('ECHO', () => {
@@ -10,10 +10,10 @@ describe('ECHO', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.echo', async client => {
testUtils.testWithClient('client.echo', async client => {
assert.equal(
await client.echo('message'),
'message'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EVAL';
describe('EVAL', () => {
@@ -13,17 +13,17 @@ describe('EVAL', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.eval', async client => {
testUtils.testWithClient('client.eval', async client => {
assert.equal(
await client.eval('return 1'),
1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.eval', async cluster => {
testUtils.testWithCluster('cluster.eval', async cluster => {
assert.equal(
await cluster.eval('return 1'),
1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EXISTS';
describe('EXISTS', () => {
@@ -19,10 +19,10 @@ describe('EXISTS', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.exists', async client => {
testUtils.testWithClient('client.exists', async client => {
assert.equal(
await client.exists('key'),
false
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EXPIRE';
describe('EXPIRE', () => {
@@ -10,10 +10,10 @@ describe('EXPIRE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.expire', async client => {
testUtils.testWithClient('client.expire', async client => {
assert.equal(
await client.expire('key', 0),
false
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './EXPIREAT';
describe('EXPIREAT', () => {
@@ -20,10 +20,10 @@ describe('EXPIREAT', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.expireAt', async client => {
testUtils.testWithClient('client.expireAt', async client => {
assert.equal(
await client.expireAt('key', 1),
false
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisFlushModes, transformArguments } from './FLUSHALL';
describe('FLUSHALL', () => {
@@ -26,10 +26,10 @@ describe('FLUSHALL', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.flushAll', async client => {
testUtils.testWithClient('client.flushAll', async client => {
assert.equal(
await client.flushAll(),
'OK'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisFlushModes } from './FLUSHALL';
import { transformArguments } from './FLUSHDB';
@@ -27,10 +27,10 @@ describe('FLUSHDB', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.flushDb', async client => {
testUtils.testWithClient('client.flushDb', async client => {
assert.equal(
await client.flushDb(),
'OK'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEOADD';
describe('GEOADD', () => {
@@ -71,7 +71,7 @@ describe('GEOADD', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.geoAdd', async client => {
testUtils.testWithClient('client.geoAdd', async client => {
assert.equal(
await client.geoAdd('key', {
member: 'member',
@@ -80,9 +80,9 @@ describe('GEOADD', () => {
}),
1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoAdd', async cluster => {
testUtils.testWithCluster('cluster.geoAdd', async cluster => {
assert.equal(
await cluster.geoAdd('key', {
member: 'member',
@@ -91,5 +91,5 @@ describe('GEOADD', () => {
}),
1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEODIST';
describe('GEODIST', () => {
@@ -20,14 +20,14 @@ describe('GEODIST', () => {
});
describe('client.geoDist', () => {
itWithClient(TestRedisServers.OPEN, 'null', async client => {
testUtils.testWithClient('null', async client => {
assert.equal(
await client.geoDist('key', '1', '2'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'with value', async client => {
testUtils.testWithClient('with value', async client => {
const [, dist] = await Promise.all([
client.geoAdd('key', [{
member: '1',
@@ -45,13 +45,13 @@ describe('GEODIST', () => {
dist,
157270.0561
);
});
}, GLOBAL.SERVERS.OPEN);
});
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoDist', async cluster => {
testUtils.testWithCluster('cluster.geoDist', async cluster => {
assert.equal(
await cluster.geoDist('key', '1', '2'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEOHASH';
describe('GEOHASH', () => {
@@ -19,17 +19,17 @@ describe('GEOHASH', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.geoHash', async client => {
testUtils.testWithClient('client.geoHash', async client => {
assert.deepEqual(
await client.geoHash('key', 'member'),
[null]
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoHash', async cluster => {
testUtils.testWithCluster('cluster.geoHash', async cluster => {
assert.deepEqual(
await cluster.geoHash('key', 'member'),
[null]
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './GEOPOS';
describe('GEOPOS', () => {
@@ -39,14 +39,14 @@ describe('GEOPOS', () => {
});
describe('client.geoPos', () => {
itWithClient(TestRedisServers.OPEN, 'null', async client => {
testUtils.testWithClient('null', async client => {
assert.deepEqual(
await client.geoPos('key', 'member'),
[null]
);
});
}, GLOBAL.SERVERS.OPEN);
itWithClient(TestRedisServers.OPEN, 'with member', async client => {
testUtils.testWithClient('with member', async client => {
const coordinates = {
longitude: '-122.06429868936538696',
latitude: '37.37749628831998194'
@@ -61,13 +61,13 @@ describe('GEOPOS', () => {
await client.geoPos('key', 'member'),
[coordinates]
);
});
}, GLOBAL.SERVERS.OPEN);
});
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoPos', async cluster => {
testUtils.testWithCluster('cluster.geoPos', async cluster => {
assert.deepEqual(
await cluster.geoPos('key', 'member'),
[null]
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEOSEARCH';
describe('GEOSEARCH', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -15,7 +15,7 @@ describe('GEOSEARCH', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.geoSearch', async client => {
testUtils.testWithClient('client.geoSearch', async client => {
assert.deepEqual(
await client.geoSearch('key', 'member', {
radius: 1,
@@ -23,9 +23,9 @@ describe('GEOSEARCH', () => {
}),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoSearch', async cluster => {
testUtils.testWithCluster('cluster.geoSearch', async cluster => {
assert.deepEqual(
await cluster.geoSearch('key', 'member', {
radius: 1,
@@ -33,5 +33,5 @@ describe('GEOSEARCH', () => {
}),
[]
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './GEOSEARCHSTORE';
describe('GEOSEARCHSTORE', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('simple', () => {
@@ -47,7 +47,7 @@ describe('GEOSEARCHSTORE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.geoSearchStore', async client => {
testUtils.testWithClient('client.geoSearchStore', async client => {
await client.geoAdd('source', {
longitude: 1,
latitude: 1,
@@ -61,9 +61,9 @@ describe('GEOSEARCHSTORE', () => {
}),
1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoSearchStore', async cluster => {
testUtils.testWithCluster('cluster.geoSearchStore', async cluster => {
await cluster.geoAdd('{tag}source', {
longitude: 1,
latitude: 1,
@@ -77,5 +77,5 @@ describe('GEOSEARCHSTORE', () => {
}),
1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,14 +1,14 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEOSEARCH_WITH';
describe('GEOSEARCH WITH', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST']
const expectedReply: RedisCommandArguments = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
@@ -20,7 +20,7 @@ describe('GEOSEARCH WITH', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.geoSearchWith', async client => {
testUtils.testWithClient('client.geoSearchWith', async client => {
assert.deepEqual(
await client.geoSearchWith('key', 'member', {
radius: 1,
@@ -28,9 +28,9 @@ describe('GEOSEARCH WITH', () => {
}, [GeoReplyWith.DISTANCE]),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoSearchWith', async cluster => {
testUtils.testWithCluster('cluster.geoSearchWith', async cluster => {
assert.deepEqual(
await cluster.geoSearchWith('key', 'member', {
radius: 1,
@@ -38,5 +38,5 @@ describe('GEOSEARCH WITH', () => {
}, [GeoReplyWith.DISTANCE]),
[]
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GET';
describe('GET', () => {
@@ -10,17 +10,17 @@ describe('GET', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.get', async client => {
testUtils.testWithClient('client.get', async client => {
assert.equal(
await client.get('key'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.get', async cluster => {
testUtils.testWithCluster('cluster.get', async cluster => {
assert.equal(
await cluster.get('key'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GETBIT';
describe('GETBIT', () => {
@@ -10,17 +10,17 @@ describe('GETBIT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.getBit', async client => {
testUtils.testWithClient('client.getBit', async client => {
assert.equal(
await client.getBit('key', 0),
0
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.getBit', async cluster => {
testUtils.testWithCluster('cluster.getBit', async cluster => {
assert.equal(
await cluster.getBit('key', 0),
0
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GETDEL';
describe('GETDEL', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,18 +12,17 @@ describe('GETDEL', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.getDel', async client => {
testUtils.testWithClient('client.getDel', async client => {
assert.equal(
await client.getDel('key'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.getDel', async cluster => {
testUtils.testWithCluster('cluster.getDel', async cluster => {
assert.equal(
await cluster.getDel('key'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GETEX';
describe('GETEX', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('EX', () => {
@@ -76,21 +76,21 @@ describe('GETEX', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.getEx', async client => {
testUtils.testWithClient('client.getEx', async client => {
assert.equal(
await client.getEx('key', {
PERSIST: true
}),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.getEx', async cluster => {
testUtils.testWithCluster('cluster.getEx', async cluster => {
assert.equal(
await cluster.getEx('key', {
PERSIST: true
}),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GETRANGE';
describe('GETRANGE', () => {
@@ -10,18 +10,17 @@ describe('GETRANGE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.getRange', async client => {
testUtils.testWithClient('client.getRange', async client => {
assert.equal(
await client.getRange('key', 0, -1),
''
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lTrim', async cluster => {
testUtils.testWithCluster('cluster.lTrim', async cluster => {
assert.equal(
await cluster.getRange('key', 0, -1),
''
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GETSET';
describe('GETSET', () => {
@@ -10,17 +10,17 @@ describe('GETSET', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.getSet', async client => {
testUtils.testWithClient('client.getSet', async client => {
assert.equal(
await client.getSet('key', 'value'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.getSet', async cluster => {
testUtils.testWithCluster('cluster.getSet', async cluster => {
assert.equal(
await cluster.getSet('key', 'value'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,22 +1,22 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
describe('GET_BUFFER', () => {
itWithClient(TestRedisServers.OPEN, 'client.getBuffer', async client => {
testUtils.testWithClient('client.getBuffer', async client => {
const buffer = Buffer.from('string');
await client.set('key', buffer);
assert.deepEqual(
buffer,
await client.getBuffer('key')
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.getBuffer', async cluster => {
testUtils.testWithCluster('cluster.getBuffer', async cluster => {
const buffer = Buffer.from('string');
await cluster.set('key', buffer);
assert.deepEqual(
buffer,
await cluster.getBuffer('key')
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HDEL';
describe('HDEL', () => {
@@ -19,10 +19,10 @@ describe('HDEL', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hDel', async client => {
testUtils.testWithClient('client.hDel', async client => {
assert.equal(
await client.hDel('key', 'field'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { REDIS_VERSION, TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HELLO';
describe('HELLO', () => {
describeHandleMinimumRedisVersion([6]);
testUtils.isVersionGreaterThanHook([6]);
describe('transformArguments', () => {
it('simple', () => {
@@ -60,20 +60,17 @@ describe('HELLO', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hello', async client => {
assert.deepEqual(
await client.hello(),
{
server: 'redis',
version: REDIS_VERSION.join('.'),
proto: 2,
id: await client.clientId(),
mode: 'standalone',
role: 'master',
modules: []
}
);
testUtils.testWithClient('client.hello', async client => {
const reply = await client.hello();
assert.equal(reply.server, 'redis');
assert.equal(typeof reply.version, 'string');
assert.equal(reply.proto, 2);
assert.equal(typeof reply.id, 'number');
assert.equal(reply.mode, 'standalone');
assert.equal(reply.role, 'master');
assert.deepEqual(reply.modules, []);
}, {
minimumRedisVersion: [6, 2]
...GLOBAL.SERVERS.OPEN,
minimumDockerVersion: [6, 2]
});
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HEXISTS';
describe('HEXISTS', () => {
@@ -10,10 +10,10 @@ describe('HEXISTS', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hExists', async client => {
testUtils.testWithClient('client.hExists', async client => {
assert.equal(
await client.hExists('key', 'field'),
false
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HGET';
describe('HGET', () => {
@@ -10,10 +10,10 @@ describe('HGET', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hGet', async client => {
testUtils.testWithClient('client.hGet', async client => {
assert.equal(
await client.hGet('key', 'field'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformReply } from './HGETALL';
describe('HGETALL', () => {
@@ -32,10 +32,10 @@ describe('HGETALL', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hGetAll', async client => {
testUtils.testWithClient('client.hGetAll', async client => {
assert.deepEqual(
await client.hGetAll('key'),
Object.create(null)
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HINCRBY';
describe('HINCRBY', () => {
@@ -10,10 +10,10 @@ describe('HINCRBY', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hIncrBy', async client => {
testUtils.testWithClient('client.hIncrBy', async client => {
assert.equal(
await client.hIncrBy('key', 'field', 1),
1
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HINCRBYFLOAT';
describe('HINCRBYFLOAT', () => {
@@ -10,10 +10,10 @@ describe('HINCRBYFLOAT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hIncrByFloat', async client => {
testUtils.testWithClient('client.hIncrByFloat', async client => {
assert.equal(
await client.hIncrByFloat('key', 'field', 1.5),
'1.5'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HKEYS';
describe('HKEYS', () => {
@@ -10,10 +10,10 @@ describe('HKEYS', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hKeys', async client => {
testUtils.testWithClient('client.hKeys', async client => {
assert.deepEqual(
await client.hKeys('key'),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HLEN';
describe('HLEN', () => {
@@ -10,10 +10,10 @@ describe('HLEN', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hLen', async client => {
testUtils.testWithClient('client.hLen', async client => {
assert.equal(
await client.hLen('key'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HMGET';
describe('HMGET', () => {
@@ -19,10 +19,10 @@ describe('HMGET', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hmGet', async client => {
testUtils.testWithClient('client.hmGet', async client => {
assert.deepEqual(
await client.hmGet('key', 'field'),
[null]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HRANDFIELD';
describe('HRANDFIELD', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,10 +12,10 @@ describe('HRANDFIELD', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hRandField', async client => {
testUtils.testWithClient('client.hRandField', async client => {
assert.equal(
await client.hRandField('key'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HRANDFIELD_COUNT';
describe('HRANDFIELD COUNT', () => {
describeHandleMinimumRedisVersion([6, 2, 5]);
testUtils.isVersionGreaterThanHook([6, 2, 5]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,10 +12,10 @@ describe('HRANDFIELD COUNT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hRandFieldCount', async client => {
testUtils.testWithClient('client.hRandFieldCount', async client => {
assert.deepEqual(
await client.hRandFieldCount('key', 1),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HRANDFIELD_COUNT_WITHVALUES';
describe('HRANDFIELD COUNT WITHVALUES', () => {
describeHandleMinimumRedisVersion([6, 2, 5]);
testUtils.isVersionGreaterThanHook([6, 2, 5]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,10 +12,10 @@ describe('HRANDFIELD COUNT WITHVALUES', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hRandFieldCountWithValues', async client => {
testUtils.testWithClient('client.hRandFieldCountWithValues', async client => {
assert.deepEqual(
await client.hRandFieldCountWithValues('key', 1),
Object.create(null)
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './HSCAN';
describe('HSCAN', () => {
@@ -65,7 +65,7 @@ describe('HSCAN', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hScan', async client => {
testUtils.testWithClient('client.hScan', async client => {
assert.deepEqual(
await client.hScan('key', 0),
{
@@ -73,5 +73,5 @@ describe('HSCAN', () => {
tuples: []
}
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import { transformArguments } from './HSET';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
describe('HSET', () => {
describe('transformArguments', () => {
@@ -33,17 +33,17 @@ describe('HSET', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.hSet', async client => {
testUtils.testWithClient('client.hSet', async client => {
assert.equal(
await client.hSet('key', 'field', 'value'),
1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.hSet', async cluster => {
testUtils.testWithCluster('cluster.hSet', async cluster => {
assert.equal(
await cluster.hSet('key', { field: 'value' }),
1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HSETNX';
describe('HSETNX', () => {
@@ -10,10 +10,10 @@ describe('HSETNX', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hSetNX', async client => {
testUtils.testWithClient('client.hSetNX', async client => {
assert.equal(
await client.hSetNX('key', 'field', 'value'),
true
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HSTRLEN';
describe('HSTRLEN', () => {
@@ -10,10 +10,10 @@ describe('HSTRLEN', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hStrLen', async client => {
testUtils.testWithClient('client.hStrLen', async client => {
assert.equal(
await client.hStrLen('key', 'field'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './HVALS';
describe('HVALS', () => {
@@ -10,10 +10,10 @@ describe('HVALS', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.hVals', async client => {
testUtils.testWithClient('client.hVals', async client => {
assert.deepEqual(
await client.hVals('key'),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './INCR';
describe('INCR', () => {
@@ -10,10 +10,10 @@ describe('INCR', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.incr', async client => {
testUtils.testWithClient('client.incr', async client => {
assert.equal(
await client.incr('key'),
1
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './INCRBY';
describe('INCR', () => {
@@ -10,10 +10,10 @@ describe('INCR', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.incrBy', async client => {
testUtils.testWithClient('client.incrBy', async client => {
assert.equal(
await client.incrBy('key', 1),
1
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './INCRBYFLOAT';
describe('INCRBYFLOAT', () => {
@@ -10,10 +10,10 @@ describe('INCRBYFLOAT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.incrByFloat', async client => {
testUtils.testWithClient('client.incrByFloat', async client => {
assert.equal(
await client.incrByFloat('key', 1.5),
'1.5'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
describe('KEYS', () => {
itWithClient(TestRedisServers.OPEN, 'client.keys', async client => {
testUtils.testWithClient('client.keys', async client => {
assert.deepEqual(
await client.keys('pattern'),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LASTSAVE';
describe('LASTSAVE', () => {
@@ -10,7 +10,7 @@ describe('LASTSAVE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lastSave', async client => {
testUtils.testWithClient('client.lastSave', async client => {
assert.ok((await client.lastSave()) instanceof Date);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LINDEX';
describe('LINDEX', () => {
@@ -10,17 +10,17 @@ describe('LINDEX', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lIndex', async client => {
testUtils.testWithClient('client.lIndex', async client => {
assert.equal(
await client.lIndex('key', 'element'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lIndex', async cluster => {
testUtils.testWithCluster('cluster.lIndex', async cluster => {
assert.equal(
await cluster.lIndex('key', 'element'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LINSERT';
describe('LINSERT', () => {
@@ -10,17 +10,17 @@ describe('LINSERT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lInsert', async client => {
testUtils.testWithClient('client.lInsert', async client => {
assert.equal(
await client.lInsert('key', 'BEFORE', 'pivot', 'element'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lLen', async cluster => {
testUtils.testWithCluster('cluster.lLen', async cluster => {
assert.equal(
await cluster.lInsert('key', 'BEFORE', 'pivot', 'element'),
0
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LLEN';
describe('LLEN', () => {
@@ -10,17 +10,17 @@ describe('LLEN', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lLen', async client => {
testUtils.testWithClient('client.lLen', async client => {
assert.equal(
await client.lLen('key'),
0
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lLen', async cluster => {
testUtils.testWithCluster('cluster.lLen', async cluster => {
assert.equal(
await cluster.lLen('key'),
0
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LMOVE';
describe('LMOVE', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,17 +12,17 @@ describe('LMOVE', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lMove', async client => {
testUtils.testWithClient('client.lMove', async client => {
assert.equal(
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lMove', async cluster => {
testUtils.testWithCluster('cluster.lMove', async cluster => {
assert.equal(
await cluster.lMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LOLWUT';
describe('LOLWUT', () => {
@@ -26,11 +26,10 @@ describe('LOLWUT', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.LOLWUT', async client => {
testUtils.testWithClient('client.LOLWUT', async client => {
assert.equal(
typeof (await client.LOLWUT()),
'string'
);
});
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOP';
describe('LPOP', () => {
@@ -10,17 +10,17 @@ describe('LPOP', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lPop', async client => {
testUtils.testWithClient('client.lPop', async client => {
assert.equal(
await client.lPop('key'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPop', async cluster => {
testUtils.testWithCluster('cluster.lPop', async cluster => {
assert.equal(
await cluster.lPop('key'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOP_COUNT';
describe('LPOP COUNT', () => {
describeHandleMinimumRedisVersion([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
@@ -12,17 +12,17 @@ describe('LPOP COUNT', () => {
);
});
itWithClient(TestRedisServers.OPEN, 'client.lPopCount', async client => {
testUtils.testWithClient('client.lPopCount', async client => {
assert.equal(
await client.lPopCount('key', 1),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPop', async cluster => {
testUtils.testWithCluster('cluster.lPopCount', async cluster => {
assert.equal(
await cluster.lPopCount('key', 1),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOS';
describe('LPOS', () => {
describeHandleMinimumRedisVersion([6, 0, 6]);
testUtils.isVersionGreaterThanHook([6, 0, 6]);
describe('transformArguments', () => {
it('simple', () => {
@@ -42,17 +42,17 @@ describe('LPOS', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.lPos', async client => {
testUtils.testWithClient('client.lPos', async client => {
assert.equal(
await client.lPos('key', 'element'),
null
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPos', async cluster => {
testUtils.testWithCluster('cluster.lPos', async cluster => {
assert.equal(
await cluster.lPos('key', 'element'),
null
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,9 +1,9 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters, describeHandleMinimumRedisVersion } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOS_COUNT';
describe('LPOS COUNT', () => {
describeHandleMinimumRedisVersion([6, 0, 6]);
testUtils.isVersionGreaterThanHook([6, 0, 6]);
describe('transformArguments', () => {
it('simple', () => {
@@ -42,17 +42,17 @@ describe('LPOS COUNT', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.lPosCount', async client => {
testUtils.testWithClient('client.lPosCount', async client => {
assert.deepEqual(
await client.lPosCount('key', 'element', 0),
[]
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPosCount', async cluster => {
testUtils.testWithCluster('cluster.lPosCount', async cluster => {
assert.deepEqual(
await cluster.lPosCount('key', 'element', 0),
[]
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

View File

@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPUSH';
describe('LPUSH', () => {
@@ -19,17 +19,17 @@ describe('LPUSH', () => {
});
});
itWithClient(TestRedisServers.OPEN, 'client.lPush', async client => {
testUtils.testWithClient('client.lPush', async client => {
assert.equal(
await client.lPush('key', 'field'),
1
);
});
}, GLOBAL.SERVERS.OPEN);
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPush', async cluster => {
testUtils.testWithCluster('cluster.lPush', async cluster => {
assert.equal(
await cluster.lPush('key', 'field'),
1
);
});
}, GLOBAL.CLUSTERS.OPEN);
});

Some files were not shown because too many files have changed in this diff Show More