You've already forked node-redis
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:
@@ -8,5 +8,8 @@
|
|||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
"plugin:@typescript-eslint/recommended"
|
"plugin:@typescript-eslint/recommended"
|
||||||
]
|
],
|
||||||
|
"rules": {
|
||||||
|
"semi": [2, "always"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [12.x, 14.x, 16.x]
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v2.3.4
|
- uses: actions/checkout@v2.3.4
|
||||||
@@ -25,17 +25,11 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
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
|
- name: Install Packages
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: npm run test
|
run: npm run test -- --forbid-only --redis-version=${{ matrix.redis-version }}
|
||||||
|
|
||||||
- name: Generate lcov
|
- name: Generate lcov
|
||||||
run: ./node_modules/.bin/nyc report -r lcov
|
run: ./node_modules/.bin/nyc report -r lcov
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"extends": "@istanbuljs/nyc-config-typescript",
|
"extends": "@istanbuljs/nyc-config-typescript",
|
||||||
"exclude": ["**/*.spec.ts", "lib/test-utils.ts"]
|
"exclude": ["**/*.spec.ts", "lib/test-utils/**/*.ts"]
|
||||||
}
|
}
|
@@ -126,7 +126,7 @@ This pattern works especially well for blocking commands—such as `BLPOP` and `
|
|||||||
```typescript
|
```typescript
|
||||||
import { commandOptions } from 'redis';
|
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']);
|
await client.lPush('key', ['1', '2']);
|
||||||
|
|
||||||
|
@@ -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`.
|
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()`.
|
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()`.
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import LinkedList from 'yallist';
|
import LinkedList from 'yallist';
|
||||||
import RedisParser from 'redis-parser';
|
import RedisParser from 'redis-parser';
|
||||||
import { AbortError } from '../errors';
|
import { AbortError } from '../errors';
|
||||||
import { RedisCommandRawReply } from '../commands';
|
import { RedisCommandArguments, RedisCommandRawReply } from '../commands';
|
||||||
|
|
||||||
export interface QueueCommandOptions {
|
export interface QueueCommandOptions {
|
||||||
asap?: boolean;
|
asap?: boolean;
|
||||||
@@ -10,7 +10,7 @@ export interface QueueCommandOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface CommandWaitingToBeSent extends CommandWaitingForReply {
|
interface CommandWaitingToBeSent extends CommandWaitingForReply {
|
||||||
args: Array<string | Buffer>;
|
args: RedisCommandArguments;
|
||||||
chainId?: symbol;
|
chainId?: symbol;
|
||||||
abort?: {
|
abort?: {
|
||||||
signal: AbortSignal;
|
signal: AbortSignal;
|
||||||
@@ -107,7 +107,7 @@ export default class RedisCommandsQueue {
|
|||||||
this.#maxLength = maxLength;
|
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) {
|
if (this.#pubSubState.subscribing || this.#pubSubState.subscribed) {
|
||||||
return Promise.reject(new Error('Cannot send commands in PubSub mode'));
|
return Promise.reject(new Error('Cannot send commands in PubSub mode'));
|
||||||
} else if (this.#maxLength && this.#waitingToBeSent.length + this.#waitingForReply.length >= this.#maxLength) {
|
} 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();
|
const toSend = this.#waitingToBeSent.shift();
|
||||||
|
|
||||||
if (toSend) {
|
if (toSend) {
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { strict as assert, AssertionError } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { once } from 'events';
|
import testUtils, { GLOBAL, waitTillBeenCalled } from '../test-utils';
|
||||||
import { itWithClient, TEST_REDIS_SERVERS, TestRedisServers, waitTillBeenCalled, isRedisVersionGreaterThan } from '../test-utils';
|
import RedisClient, { RedisClientType } from '.';
|
||||||
import RedisClient from '.';
|
import { RedisClientMultiCommandType } from './multi-command';
|
||||||
import { AbortError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, WatchError } from '../errors';
|
import { RedisCommandArguments, RedisCommandRawReply, RedisModules, RedisScripts } from '../commands';
|
||||||
|
import { AbortError, ClientClosedError, ConnectionTimeoutError, DisconnectsClientError, SocketClosedUnexpectedlyError, WatchError } from '../errors';
|
||||||
import { defineScript } from '../lua-script';
|
import { defineScript } from '../lua-script';
|
||||||
import { spy } from 'sinon';
|
import { spy } from 'sinon';
|
||||||
import { RedisNetSocketOptions } from '../client/socket';
|
import { once } from 'events';
|
||||||
|
|
||||||
export const SQUARE_SCRIPT = defineScript({
|
export const SQUARE_SCRIPT = defineScript({
|
||||||
NUMBER_OF_KEYS: 0,
|
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', () => {
|
describe('authentication', () => {
|
||||||
itWithClient(TestRedisServers.PASSWORD, 'Client should be authenticated', async client => {
|
testUtils.testWithClient('Client should be authenticated', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.ping(),
|
await client.ping(),
|
||||||
'PONG'
|
'PONG'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.PASSWORD);
|
||||||
|
|
||||||
it('should not retry connecting if failed due to wrong auth', async () => {
|
|
||||||
const client = RedisClient.create({
|
|
||||||
...TEST_REDIS_SERVERS[TestRedisServers.PASSWORD],
|
|
||||||
password: 'wrongpassword'
|
|
||||||
});
|
|
||||||
|
|
||||||
|
testUtils.testWithClient('should not retry connecting if failed due to wrong auth', async client => {
|
||||||
let message;
|
let message;
|
||||||
if (isRedisVersionGreaterThan([6, 2])) {
|
if (testUtils.isVersionGreaterThan([6, 2])) {
|
||||||
message = 'WRONGPASS invalid username-password pair or user is disabled.';
|
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';
|
message = 'WRONGPASS invalid username-password pair';
|
||||||
} else {
|
} else {
|
||||||
message = 'ERR invalid password';
|
message = 'ERR invalid password';
|
||||||
@@ -123,173 +102,216 @@ describe('Client', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(client.isOpen, false);
|
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(
|
assert.equal(
|
||||||
(await client.clientInfo()).db,
|
(await client.clientInfo()).db,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
minimumRedisVersion: [6, 2],
|
...GLOBAL.SERVERS.PASSWORD,
|
||||||
clientOptions: {
|
clientOptions: {
|
||||||
|
...GLOBAL.SERVERS.PASSWORD.clientOptions,
|
||||||
database: 2
|
database: 2
|
||||||
}
|
},
|
||||||
|
minimumDockerVersion: [6, 2]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('legacyMode', () => {
|
describe('legacyMode', () => {
|
||||||
const client = RedisClient.create({
|
function sendCommandAsync<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>, args: RedisCommandArguments): Promise<RedisCommandRawReply> {
|
||||||
...TEST_REDIS_SERVERS[TestRedisServers.OPEN],
|
return new Promise((resolve, reject) => {
|
||||||
scripts: {
|
(client as any).sendCommand(args, (err: Error | undefined, reply: RedisCommandRawReply) => {
|
||||||
square: SQUARE_SCRIPT
|
if (err) return reject(err);
|
||||||
},
|
|
||||||
legacyMode: true
|
|
||||||
});
|
|
||||||
|
|
||||||
before(() => client.connect());
|
resolve(reply);
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.sendCommand should call the callback', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await sendCommandAsync(client, ['PING']),
|
||||||
|
'PONG'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.sendCommand should work without callback', async () => {
|
testUtils.testWithClient('client.sendCommand should work without callback', async client => {
|
||||||
(client as any).sendCommand('PING');
|
client.sendCommand(['PING']);
|
||||||
await client.v4.ping(); // make sure the first command was replied
|
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(
|
assert.equal(
|
||||||
await client.v4.sendCommand(['PING']),
|
await client.v4.sendCommand(['PING']),
|
||||||
'PONG'
|
'PONG'
|
||||||
);
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.{command} should accept vardict arguments', done => {
|
function setAsync<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>, ...args: Array<string | Buffer | RedisCommandArguments>): Promise<RedisCommandRawReply> {
|
||||||
(client as any).set('a', 'b', (err?: Error, reply?: string) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
(client as any).set(...args, (err: Error | undefined, reply: RedisCommandRawReply) => {
|
||||||
return done(err);
|
if (err) return reject(err);
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
resolve(reply);
|
||||||
assert.equal(reply, 'OK');
|
|
||||||
done();
|
|
||||||
} catch (err) {
|
|
||||||
done(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('client.{command} should accept arguments array', 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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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 vardict arguments', async client => {
|
||||||
|
assert.equal(
|
||||||
|
await setAsync(client, 'a', 'b'),
|
||||||
|
'OK'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.multi.ping.exec should work without callback', async () => {
|
testUtils.testWithClient('client.{command} should accept arguments array', async client => {
|
||||||
(client as any).multi()
|
assert.equal(
|
||||||
|
await setAsync(client, ['a', 'b']),
|
||||||
|
'OK'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.multi.ping.exec should call the callback', async client => {
|
||||||
|
client.multi()
|
||||||
.ping()
|
.ping()
|
||||||
.exec();
|
.exec();
|
||||||
await client.v4.ping(); // make sure the first command was replied
|
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(
|
assert.deepEqual(
|
||||||
await ((client as any).multi()
|
await client.multi()
|
||||||
.ping()
|
.ping()
|
||||||
.v4.ping()
|
.v4.ping()
|
||||||
.v4.exec()),
|
.v4.exec(),
|
||||||
['PONG', 'PONG']
|
['PONG', 'PONG']
|
||||||
);
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.{script} should return a promise', async () => {
|
testUtils.testWithClient('client.{script} should return a promise', async client => {
|
||||||
assert.equal(await client.square(2), 4);
|
assert.equal(
|
||||||
|
await client.square(2),
|
||||||
|
4
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
|
legacyMode: true,
|
||||||
|
scripts: {
|
||||||
|
square: SQUARE_SCRIPT
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('events', () => {
|
describe('events', () => {
|
||||||
it('connect, ready, end', async () => {
|
testUtils.testWithClient('connect, ready, end', async client => {
|
||||||
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
client.connect(),
|
|
||||||
once(client, 'connect'),
|
once(client, 'connect'),
|
||||||
once(client, 'ready')
|
once(client, 'ready'),
|
||||||
|
client.connect()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
client.disconnect(),
|
once(client, 'end'),
|
||||||
once(client, 'end')
|
client.disconnect()
|
||||||
]);
|
]);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
disableClientSetup: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('sendCommand', () => {
|
describe('sendCommand', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'PING', async client => {
|
testUtils.testWithClient('PING', async client => {
|
||||||
assert.equal(await client.sendCommand(['PING']), 'PONG');
|
assert.equal(await client.sendCommand(['PING']), 'PONG');
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'bufferMode', async client => {
|
testUtils.testWithClient('bufferMode', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sendCommand(['PING'], undefined, true),
|
await client.sendCommand(['PING'], undefined, true),
|
||||||
Buffer.from('PONG')
|
Buffer.from('PONG')
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
describe('AbortController', () => {
|
describe('AbortController', () => {
|
||||||
before(function () {
|
before(function () {
|
||||||
@@ -298,13 +320,13 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'success', async client => {
|
testUtils.testWithClient('success', async client => {
|
||||||
await client.sendCommand(['PING'], {
|
await client.sendCommand(['PING'], {
|
||||||
signal: new AbortController().signal
|
signal: new AbortController().signal
|
||||||
});
|
});
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'AbortError', client => {
|
testUtils.testWithClient('AbortError', client => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
controller.abort();
|
controller.abort();
|
||||||
|
|
||||||
@@ -314,12 +336,12 @@ describe('Client', () => {
|
|||||||
}),
|
}),
|
||||||
AbortError
|
AbortError
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('multi', () => {
|
describe('multi', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'simple', async client => {
|
testUtils.testWithClient('simple', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.multi()
|
await client.multi()
|
||||||
.ping()
|
.ping()
|
||||||
@@ -328,23 +350,19 @@ describe('Client', () => {
|
|||||||
.exec(),
|
.exec(),
|
||||||
['PONG', 'OK', 'value']
|
['PONG', 'OK', 'value']
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'should reject the whole chain on error', client => {
|
|
||||||
client.on('error', () => {
|
|
||||||
// ignore errors
|
|
||||||
});
|
|
||||||
|
|
||||||
|
testUtils.testWithClient('should reject the whole chain on error', client => {
|
||||||
return assert.rejects(
|
return assert.rejects(
|
||||||
client.multi()
|
client.multi()
|
||||||
.ping()
|
.ping()
|
||||||
.addCommand(['DEBUG', 'RESTART'])
|
.addCommand(['INVALID COMMAND'])
|
||||||
.ping()
|
.ping()
|
||||||
.exec()
|
.exec()
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'with script', async client => {
|
testUtils.testWithClient('with script', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.multi()
|
await client.multi()
|
||||||
.square(2)
|
.square(2)
|
||||||
@@ -352,6 +370,7 @@ describe('Client', () => {
|
|||||||
[4]
|
[4]
|
||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
clientOptions: {
|
clientOptions: {
|
||||||
scripts: {
|
scripts: {
|
||||||
square: SQUARE_SCRIPT
|
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.watch('key');
|
||||||
|
|
||||||
await client.set(
|
await client.set(
|
||||||
@@ -376,24 +395,25 @@ describe('Client', () => {
|
|||||||
.exec(),
|
.exec(),
|
||||||
WatchError
|
WatchError
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'execAsPipeline', async client => {
|
testUtils.testWithClient('execAsPipeline', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.multi()
|
await client.multi()
|
||||||
.ping()
|
.ping()
|
||||||
.exec(true),
|
.exec(true),
|
||||||
['PONG']
|
['PONG']
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'scripts', async client => {
|
testUtils.testWithClient('scripts', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.square(2),
|
await client.square(2),
|
||||||
4
|
4
|
||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
clientOptions: {
|
clientOptions: {
|
||||||
scripts: {
|
scripts: {
|
||||||
square: SQUARE_SCRIPT
|
square: SQUARE_SCRIPT
|
||||||
@@ -401,12 +421,13 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'modules', async client => {
|
testUtils.testWithClient('modules', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.module.echo('message'),
|
await client.module.echo('message'),
|
||||||
'message'
|
'message'
|
||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
clientOptions: {
|
clientOptions: {
|
||||||
modules: {
|
modules: {
|
||||||
module: {
|
module: {
|
||||||
@@ -423,7 +444,7 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'executeIsolated', async client => {
|
testUtils.testWithClient('executeIsolated', async client => {
|
||||||
await client.sendCommand(['CLIENT', 'SETNAME', 'client']);
|
await client.sendCommand(['CLIENT', 'SETNAME', 'client']);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@@ -432,35 +453,35 @@ describe('Client', () => {
|
|||||||
),
|
),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'should reconnect after DEBUG RESTART', async client => {
|
async function killClient<M extends RedisModules, S extends RedisScripts>(client: RedisClientType<M, S>): Promise<void> {
|
||||||
client.on('error', () => {
|
const onceErrorPromise = once(client, 'error');
|
||||||
// ignore errors
|
await client.sendCommand(['QUIT']);
|
||||||
});
|
await Promise.all([
|
||||||
|
onceErrorPromise,
|
||||||
|
assert.rejects(client.ping(), SocketClosedUnexpectedlyError)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
await client.sendCommand(['CLIENT', 'SETNAME', 'client']);
|
testUtils.testWithClient('should reconnect when socket disconnects', async client => {
|
||||||
await assert.rejects(client.sendCommand(['DEBUG', 'RESTART']));
|
await killClient(client);
|
||||||
assert.ok(await client.sendCommand(['CLIENT', 'GETNAME']) === null);
|
await assert.doesNotReject(client.ping());
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'should SELECT db after reconnection', async client => {
|
|
||||||
client.on('error', () => {
|
|
||||||
// ignore errors
|
|
||||||
});
|
|
||||||
|
|
||||||
|
testUtils.testWithClient('should remember selected db', async client => {
|
||||||
await client.select(1);
|
await client.select(1);
|
||||||
await assert.rejects(client.sendCommand(['DEBUG', 'RESTART']));
|
await killClient(client);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
(await client.clientInfo()).db,
|
(await client.clientInfo()).db,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
}, {
|
}, {
|
||||||
// because of CLIENT INFO
|
...GLOBAL.SERVERS.OPEN,
|
||||||
minimumRedisVersion: [6, 2]
|
minimumDockerVersion: [6, 2] // CLIENT INFO
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'scanIterator', async client => {
|
testUtils.testWithClient('scanIterator', async client => {
|
||||||
const promises = [],
|
const promises = [],
|
||||||
keys = new Set();
|
keys = new Set();
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
@@ -477,9 +498,9 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.deepEqual(keys, results);
|
assert.deepEqual(keys, results);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'hScanIterator', async client => {
|
testUtils.testWithClient('hScanIterator', async client => {
|
||||||
const hash: Record<string, string> = {};
|
const hash: Record<string, string> = {};
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
hash[i.toString()] = i.toString();
|
hash[i.toString()] = i.toString();
|
||||||
@@ -493,9 +514,9 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.deepEqual(hash, results);
|
assert.deepEqual(hash, results);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'sScanIterator', async client => {
|
testUtils.testWithClient('sScanIterator', async client => {
|
||||||
const members = new Set<string>();
|
const members = new Set<string>();
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
members.add(i.toString());
|
members.add(i.toString());
|
||||||
@@ -509,9 +530,9 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.deepEqual(members, results);
|
assert.deepEqual(members, results);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'zScanIterator', async client => {
|
testUtils.testWithClient('zScanIterator', async client => {
|
||||||
const members = [];
|
const members = [];
|
||||||
for (let i = 0; i < 100; i++) {
|
for (let i = 0; i < 100; i++) {
|
||||||
members.push({
|
members.push({
|
||||||
@@ -537,9 +558,9 @@ describe('Client', () => {
|
|||||||
[...map.entries()].sort(sort),
|
[...map.entries()].sort(sort),
|
||||||
members.map<MemberTuple>(member => [member.value, member.score]).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();
|
const subscriber = publisher.duplicate();
|
||||||
|
|
||||||
await subscriber.connect();
|
await subscriber.connect();
|
||||||
@@ -602,76 +623,59 @@ describe('Client', () => {
|
|||||||
} finally {
|
} finally {
|
||||||
await subscriber.disconnect();
|
await subscriber.disconnect();
|
||||||
}
|
}
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
it('ConnectionTimeoutError', async () => {
|
testUtils.testWithClient('ConnectionTimeoutError', async client => {
|
||||||
const client = RedisClient.create({
|
const promise = assert.rejects(client.connect(), ConnectionTimeoutError),
|
||||||
|
start = process.hrtime.bigint();
|
||||||
|
|
||||||
|
while (process.hrtime.bigint() - start < 1_000_000) {
|
||||||
|
// block the event loop for 1ms, to make sure the connection will timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
await promise;
|
||||||
|
}, {
|
||||||
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
clientOptions: {
|
||||||
socket: {
|
socket: {
|
||||||
...TEST_REDIS_SERVERS[TestRedisServers.OPEN],
|
|
||||||
connectTimeout: 1
|
connectTimeout: 1
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
disableClientSetup: true
|
||||||
try {
|
|
||||||
const promise = assert.rejects(client.connect(), ConnectionTimeoutError),
|
|
||||||
start = process.hrtime.bigint();
|
|
||||||
|
|
||||||
while (process.hrtime.bigint() - start < 1_000_000) {
|
|
||||||
// block the event loop for 1ms, to make sure the connection will timeout
|
|
||||||
}
|
|
||||||
|
|
||||||
await promise;
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof AssertionError) {
|
|
||||||
await client.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.quit', async () => {
|
testUtils.testWithClient('client.quit', async client => {
|
||||||
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
|
|
||||||
|
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
|
||||||
try {
|
const pingPromise = client.ping(),
|
||||||
const pingPromise = client.ping(),
|
quitPromise = client.quit();
|
||||||
quitPromise = client.quit();
|
assert.equal(client.isOpen, false);
|
||||||
assert.equal(client.isOpen, false);
|
|
||||||
|
|
||||||
const [ping] = await Promise.all([
|
const [ping] = await Promise.all([
|
||||||
pingPromise,
|
pingPromise,
|
||||||
assert.doesNotReject(quitPromise),
|
assert.doesNotReject(quitPromise),
|
||||||
assert.rejects(client.ping(), ClientClosedError)
|
assert.rejects(client.ping(), ClientClosedError)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert.equal(ping, 'PONG');
|
assert.equal(ping, 'PONG');
|
||||||
} finally {
|
}, {
|
||||||
if (client.isOpen) {
|
...GLOBAL.SERVERS.OPEN,
|
||||||
await client.disconnect();
|
disableClientSetup: true
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('client.disconnect', async () => {
|
testUtils.testWithClient('client.disconnect', async client => {
|
||||||
const client = RedisClient.create(TEST_REDIS_SERVERS[TestRedisServers.OPEN]);
|
|
||||||
|
|
||||||
await client.connect();
|
await client.connect();
|
||||||
|
|
||||||
try {
|
const pingPromise = client.ping(),
|
||||||
const pingPromise = client.ping(),
|
disconnectPromise = client.disconnect();
|
||||||
disconnectPromise = client.disconnect();
|
assert.equal(client.isOpen, false);
|
||||||
assert.equal(client.isOpen, false);
|
await Promise.all([
|
||||||
await Promise.all([
|
assert.rejects(pingPromise, DisconnectsClientError),
|
||||||
assert.rejects(pingPromise, DisconnectsClientError),
|
assert.doesNotReject(disconnectPromise),
|
||||||
assert.doesNotReject(disconnectPromise),
|
assert.rejects(client.ping(), ClientClosedError)
|
||||||
assert.rejects(client.ping(), ClientClosedError)
|
]);
|
||||||
]);
|
}, {
|
||||||
} finally {
|
...GLOBAL.SERVERS.OPEN,
|
||||||
if (client.isOpen) {
|
disableClientSetup: true
|
||||||
await client.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -9,7 +9,7 @@ import { CommandOptions, commandOptions, isCommandOptions } from '../command-opt
|
|||||||
import { ScanOptions, ZMember } from '../commands/generic-transformers';
|
import { ScanOptions, ZMember } from '../commands/generic-transformers';
|
||||||
import { ScanCommandOptions } from '../commands/SCAN';
|
import { ScanCommandOptions } from '../commands/SCAN';
|
||||||
import { HScanTuple } from '../commands/HSCAN';
|
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 { Pool, Options as PoolOptions, createPool } from 'generic-pool';
|
||||||
import { ClientClosedError, DisconnectsClientError } from '../errors';
|
import { ClientClosedError, DisconnectsClientError } from '../errors';
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
@@ -217,7 +217,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (promises.length) {
|
if (promises.length) {
|
||||||
this.#tick();
|
this.#tick(true);
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -435,8 +435,8 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
|||||||
|
|
||||||
quit = this.QUIT;
|
quit = this.QUIT;
|
||||||
|
|
||||||
#tick(): void {
|
#tick(force = false): void {
|
||||||
if (!this.#socket.isSocketExists || this.#socket.writableNeedDrain) {
|
if (this.#socket.writableNeedDrain || (!force && !this.#socket.isReady)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,9 +446,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
|||||||
const args = this.#queue.getCommandToSend();
|
const args = this.#queue.getCommandToSend();
|
||||||
if (args === undefined) break;
|
if (args === undefined) break;
|
||||||
|
|
||||||
for (const toWrite of encodeCommand(args)) {
|
this.#socket.writeCommand(args);
|
||||||
this.#socket.write(toWrite);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +483,7 @@ export default class RedisClient<M extends RedisModules, S extends RedisScripts>
|
|||||||
for (const key of reply.keys) {
|
for (const key of reply.keys) {
|
||||||
yield key;
|
yield key;
|
||||||
}
|
}
|
||||||
} while (cursor !== 0)
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* hScanIterator(key: string, options?: ScanOptions): AsyncIterable<HScanTuple> {
|
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) {
|
for (const tuple of reply.tuples) {
|
||||||
yield tuple;
|
yield tuple;
|
||||||
}
|
}
|
||||||
} while (cursor !== 0)
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* sScanIterator(key: string, options?: ScanOptions): AsyncIterable<string> {
|
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) {
|
for (const member of reply.members) {
|
||||||
yield member;
|
yield member;
|
||||||
}
|
}
|
||||||
} while (cursor !== 0)
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async* zScanIterator(key: string, options?: ScanOptions): AsyncIterable<ZMember> {
|
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) {
|
for (const member of reply.members) {
|
||||||
yield member;
|
yield member;
|
||||||
}
|
}
|
||||||
} while (cursor !== 0)
|
} while (cursor !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnect(): Promise<void> {
|
async disconnect(): Promise<void> {
|
||||||
this.#queue.flushAll(new DisconnectsClientError());
|
this.#queue.flushAll(new DisconnectsClientError());
|
||||||
await Promise.all([
|
this.#socket.disconnect();
|
||||||
this.#socket.disconnect(),
|
await this.#destroyIsolationPool();
|
||||||
this.#destroyIsolationPool()
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #destroyIsolationPool(): Promise<void> {
|
async #destroyIsolationPool(): Promise<void> {
|
||||||
|
@@ -33,6 +33,6 @@ describe('Socket', () => {
|
|||||||
return assert.rejects(socket.connect(), {
|
return assert.rejects(socket.connect(), {
|
||||||
message: '50'
|
message: '50'
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import EventEmitter from 'events';
|
import EventEmitter from 'events';
|
||||||
import net from 'net';
|
import net from 'net';
|
||||||
import tls from 'tls';
|
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';
|
import { promiseTimeout } from '../utils';
|
||||||
|
|
||||||
export interface RedisSocketCommonOptions {
|
export interface RedisSocketCommonOptions {
|
||||||
@@ -72,8 +74,10 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
return this.#isOpen;
|
return this.#isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isSocketExists(): boolean {
|
#isReady = false;
|
||||||
return !!this.#socket;
|
|
||||||
|
get isReady(): boolean {
|
||||||
|
return this.#isReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
// `writable.writableNeedDrain` was added in v15.2.0 and therefore can't be used
|
// `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> {
|
async connect(): Promise<void> {
|
||||||
if (this.#isOpen) {
|
if (this.#isOpen) {
|
||||||
throw new Error('Socket is connection/connecting');
|
throw new Error('Socket already opened');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#isOpen = true;
|
return this.#connect();
|
||||||
|
|
||||||
try {
|
|
||||||
await this.#connect();
|
|
||||||
} catch (err) {
|
|
||||||
this.#isOpen = false;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #connect(hadError?: boolean): Promise<void> {
|
async #connect(hadError?: boolean): Promise<void> {
|
||||||
|
this.#isOpen = true;
|
||||||
this.#socket = await this.#retryConnection(0, hadError);
|
this.#socket = await this.#retryConnection(0, hadError);
|
||||||
|
this.#writableNeedDrain = false;
|
||||||
|
|
||||||
|
if (!this.#isOpen) {
|
||||||
|
this.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.emit('connect');
|
this.emit('connect');
|
||||||
|
|
||||||
if (this.#initiator) {
|
if (this.#initiator) {
|
||||||
try {
|
try {
|
||||||
await this.#initiator();
|
await this.#initiator();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.#socket.end();
|
this.#socket.destroy();
|
||||||
this.#socket = undefined;
|
this.#socket = undefined;
|
||||||
|
this.#isOpen = false;
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.#isOpen) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#isReady = true;
|
||||||
|
|
||||||
this.emit('ready');
|
this.emit('ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +178,7 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
.once('error', (err: Error) => this.#onSocketError(err))
|
.once('error', (err: Error) => this.#onSocketError(err))
|
||||||
.once('close', hadError => {
|
.once('close', hadError => {
|
||||||
if (!hadError && this.#isOpen) {
|
if (!hadError && this.#isOpen) {
|
||||||
this.#onSocketError(new Error('Socket closed unexpectedly'));
|
this.#onSocketError(new SocketClosedUnexpectedlyError());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('drain', () => {
|
.on('drain', () => {
|
||||||
@@ -197,33 +207,32 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onSocketError(err: Error): void {
|
#onSocketError(err: Error): void {
|
||||||
this.#socket = undefined;
|
this.#isReady = false;
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
|
|
||||||
this.#connect(true)
|
this.#connect(true).catch(() => {
|
||||||
.catch(err => this.emit('error', err));
|
// the error was already emitted, silently ignore it
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
write(toWrite: string | Buffer): boolean {
|
writeCommand(args: RedisCommandArguments): void {
|
||||||
if (!this.#socket) {
|
if (!this.#socket) {
|
||||||
throw new ClientClosedError();
|
throw new ClientClosedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
const wasFullyWritten = this.#socket.write(toWrite);
|
for (const toWrite of encodeCommand(args)) {
|
||||||
this.#writableNeedDrain = !wasFullyWritten;
|
this.#writableNeedDrain = !this.#socket.write(toWrite);
|
||||||
return wasFullyWritten;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnect(ignoreIsOpen = false): Promise<void> {
|
disconnect(): void {
|
||||||
if ((!ignoreIsOpen && !this.#isOpen) || !this.#socket) {
|
if (!this.#socket) {
|
||||||
throw new ClientClosedError();
|
throw new ClientClosedError();
|
||||||
} else {
|
} else {
|
||||||
this.#isOpen = false;
|
this.#isOpen = this.#isReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#socket.end();
|
this.#socket.destroy();
|
||||||
this.#socket.removeAllListeners('data');
|
|
||||||
await EventEmitter.once(this.#socket, 'end');
|
|
||||||
this.#socket = undefined;
|
this.#socket = undefined;
|
||||||
this.emit('end');
|
this.emit('end');
|
||||||
}
|
}
|
||||||
@@ -234,14 +243,8 @@ export default class RedisSocket extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.#isOpen = false;
|
this.#isOpen = false;
|
||||||
|
await fn();
|
||||||
try {
|
this.disconnect();
|
||||||
await fn();
|
|
||||||
await this.disconnect(true);
|
|
||||||
} catch (err) {
|
|
||||||
this.#isOpen = true;
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#isCorked = false;
|
#isCorked = false;
|
||||||
|
@@ -1,17 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import RedisCluster from '.';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { defineScript } from '../lua-script';
|
|
||||||
import { itWithCluster, itWithDedicatedCluster, TestRedisClusters, TEST_REDIS_CLUSTERES } from '../test-utils';
|
|
||||||
import calculateSlot from 'cluster-key-slot';
|
import calculateSlot from 'cluster-key-slot';
|
||||||
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT';
|
import { ClusterSlotStates } from '../commands/CLUSTER_SETSLOT';
|
||||||
|
import { SQUARE_SCRIPT } from '../client/index.spec';
|
||||||
|
|
||||||
describe('Cluster', () => {
|
describe('Cluster', () => {
|
||||||
it('sendCommand', async () => {
|
testUtils.testWithCluster('sendCommand', async cluster => {
|
||||||
const cluster = RedisCluster.create({
|
|
||||||
...TEST_REDIS_CLUSTERES[TestRedisClusters.OPEN],
|
|
||||||
useReplicas: true
|
|
||||||
});
|
|
||||||
|
|
||||||
await cluster.connect();
|
await cluster.connect();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -26,9 +20,9 @@ describe('Cluster', () => {
|
|||||||
} finally {
|
} finally {
|
||||||
await cluster.disconnect();
|
await cluster.disconnect();
|
||||||
}
|
}
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'multi', async cluster => {
|
testUtils.testWithCluster('multi', async cluster => {
|
||||||
const key = 'key';
|
const key = 'key';
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await cluster.multi()
|
await cluster.multi()
|
||||||
@@ -37,40 +31,23 @@ describe('Cluster', () => {
|
|||||||
.exec(),
|
.exec(),
|
||||||
['OK', 'value']
|
['OK', 'value']
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
|
|
||||||
it('scripts', async () => {
|
testUtils.testWithCluster('scripts', async cluster => {
|
||||||
const cluster = RedisCluster.create({
|
assert.equal(
|
||||||
...TEST_REDIS_CLUSTERES[TestRedisClusters.OPEN],
|
await cluster.square(2),
|
||||||
|
4
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
...GLOBAL.CLUSTERS.OPEN,
|
||||||
|
clusterConfiguration: {
|
||||||
scripts: {
|
scripts: {
|
||||||
add: defineScript({
|
square: SQUARE_SCRIPT
|
||||||
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 {
|
|
||||||
assert.equal(
|
|
||||||
await cluster.add(1),
|
|
||||||
2
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
await cluster.disconnect();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithDedicatedCluster('should handle live resharding', async cluster => {
|
testUtils.testWithCluster('should handle live resharding', async cluster => {
|
||||||
const key = 'key',
|
const key = 'key',
|
||||||
value = 'value';
|
value = 'value';
|
||||||
await cluster.set(key, value);
|
await cluster.set(key, value);
|
||||||
@@ -110,5 +87,7 @@ describe('Cluster', () => {
|
|||||||
await cluster.get(key),
|
await cluster.get(key),
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
|
}, {
|
||||||
|
serverArguments: []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_CAT';
|
import { transformArguments } from './ACL_CAT';
|
||||||
|
|
||||||
describe('ACL CAT', () => {
|
describe('ACL CAT', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion, itWithClient, TestRedisServers } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './ACL_DELUSER';
|
import { transformArguments } from './ACL_DELUSER';
|
||||||
|
|
||||||
describe('ACL DELUSER', () => {
|
describe('ACL DELUSER', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
@@ -21,10 +21,10 @@ describe('ACL DELUSER', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.aclDelUser', async client => {
|
testUtils.testWithClient('client.aclDelUser', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.aclDelUser('dosenotexists'),
|
await client.aclDelUser('dosenotexists'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_GENPASS';
|
import { transformArguments } from './ACL_GENPASS';
|
||||||
|
|
||||||
describe('ACL GENPASS', () => {
|
describe('ACL GENPASS', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './ACL_GETUSER';
|
||||||
|
|
||||||
describe('ACL GETUSER', () => {
|
describe('ACL GETUSER', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,14 +12,14 @@ describe('ACL GETUSER', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.aclGetUser', async client => {
|
testUtils.testWithClient('client.aclGetUser', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.aclGetUser('default'),
|
await client.aclGetUser('default'),
|
||||||
{
|
{
|
||||||
passwords: [],
|
passwords: [],
|
||||||
commands: '+@all',
|
commands: '+@all',
|
||||||
keys: ['*'],
|
keys: ['*'],
|
||||||
...(isRedisVersionGreaterThan([6, 2]) ? {
|
...(testUtils.isVersionGreaterThan([6, 2]) ? {
|
||||||
flags: ['on', 'allkeys', 'allchannels', 'allcommands', 'nopass'],
|
flags: ['on', 'allkeys', 'allchannels', 'allcommands', 'nopass'],
|
||||||
channels: ['*']
|
channels: ['*']
|
||||||
} : {
|
} : {
|
||||||
@@ -28,5 +28,5 @@ describe('ACL GETUSER', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_LIST';
|
import { transformArguments } from './ACL_LIST';
|
||||||
|
|
||||||
describe('ACL LIST', () => {
|
describe('ACL LIST', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_SAVE';
|
import { transformArguments } from './ACL_SAVE';
|
||||||
|
|
||||||
describe('ACL SAVE', () => {
|
describe('ACL SAVE', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './ACL_LOG';
|
import { transformArguments, transformReply } from './ACL_LOG';
|
||||||
|
|
||||||
describe('ACL LOG', () => {
|
describe('ACL LOG', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_LOG_RESET';
|
import { transformArguments } from './ACL_LOG_RESET';
|
||||||
|
|
||||||
describe('ACL LOG RESET', () => {
|
describe('ACL LOG RESET', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_LOAD';
|
import { transformArguments } from './ACL_LOAD';
|
||||||
|
|
||||||
describe('ACL LOAD', () => {
|
describe('ACL LOAD', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_SETUSER';
|
import { transformArguments } from './ACL_SETUSER';
|
||||||
|
|
||||||
describe('ACL SETUSER', () => {
|
describe('ACL SETUSER', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_USERS';
|
import { transformArguments } from './ACL_USERS';
|
||||||
|
|
||||||
describe('ACL USERS', () => {
|
describe('ACL USERS', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils from '../test-utils';
|
||||||
import { transformArguments } from './ACL_WHOAMI';
|
import { transformArguments } from './ACL_WHOAMI';
|
||||||
|
|
||||||
describe('ACL WHOAMI', () => {
|
describe('ACL WHOAMI', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './APPEND';
|
import { transformArguments } from './APPEND';
|
||||||
|
|
||||||
describe('AUTH', () => {
|
describe('APPEND', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 'value'),
|
transformArguments('key', 'value'),
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './BITCOUNT';
|
import { transformArguments } from './BITCOUNT';
|
||||||
|
|
||||||
describe('BITCOUNT', () => {
|
describe('BITCOUNT', () => {
|
||||||
@@ -22,10 +22,10 @@ describe('BITCOUNT', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.bitCount', async client => {
|
testUtils.testWithClient('client.bitCount', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.bitCount('key'),
|
await client.bitCount('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './BITFIELD';
|
import { transformArguments } from './BITFIELD';
|
||||||
|
|
||||||
describe('BITFIELD', () => {
|
describe('BITFIELD', () => {
|
||||||
@@ -33,10 +33,10 @@ describe('BITFIELD', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.bitField', async client => {
|
testUtils.testWithClient('client.bitField', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.bitField('key', []),
|
await client.bitField('key', []),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './BITOP';
|
import { transformArguments } from './BITOP';
|
||||||
|
|
||||||
describe('BITOP', () => {
|
describe('BITOP', () => {
|
||||||
@@ -19,17 +19,17 @@ describe('BITOP', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.bitOp', async client => {
|
testUtils.testWithClient('client.bitOp', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.bitOp('AND', 'destKey', 'key'),
|
await client.bitOp('AND', 'destKey', 'key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.bitOp', async cluster => {
|
testUtils.testWithCluster('cluster.bitOp', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.bitOp('AND', '{tag}destKey', '{tag}key'),
|
await cluster.bitOp('AND', '{tag}destKey', '{tag}key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './BITPOS';
|
import { transformArguments } from './BITPOS';
|
||||||
|
|
||||||
describe('BITPOS', () => {
|
describe('BITPOS', () => {
|
||||||
@@ -26,17 +26,17 @@ describe('BITPOS', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.bitPos', async client => {
|
testUtils.testWithClient('client.bitPos', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.bitPos('key', 1, 1),
|
await client.bitPos('key', 1, 1),
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.bitPos', async cluster => {
|
testUtils.testWithCluster('cluster.bitPos', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.bitPos('key', 1, 1),
|
await cluster.bitPos('key', 1, 1),
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
import { strict as assert } from 'assert';
|
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 { transformArguments } from './BLMOVE';
|
||||||
import { commandOptions } from '../../index';
|
import { commandOptions } from '../../index';
|
||||||
|
|
||||||
describe('BLMOVE', () => {
|
describe('BLMOVE', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
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([
|
const [blMoveReply] = await Promise.all([
|
||||||
client.blMove(commandOptions({
|
client.blMove(commandOptions({
|
||||||
isolated: true
|
isolated: true
|
||||||
@@ -25,9 +25,9 @@ describe('BLMOVE', () => {
|
|||||||
blMoveReply,
|
blMoveReply,
|
||||||
'element'
|
'element'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.blMove', async cluster => {
|
testUtils.testWithCluster('cluster.blMove', async cluster => {
|
||||||
const [blMoveReply] = await Promise.all([
|
const [blMoveReply] = await Promise.all([
|
||||||
cluster.blMove(commandOptions({
|
cluster.blMove(commandOptions({
|
||||||
isolated: true
|
isolated: true
|
||||||
@@ -39,5 +39,5 @@ describe('BLMOVE', () => {
|
|||||||
blMoveReply,
|
blMoveReply,
|
||||||
'element'
|
'element'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
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 { transformArguments, transformReply } from './BLPOP';
|
||||||
import { commandOptions } from '../../index';
|
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([
|
const [ blPopReply ] = await Promise.all([
|
||||||
client.blPop(
|
client.blPop(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -56,9 +56,9 @@ describe('BLPOP', () => {
|
|||||||
element: 'element'
|
element: 'element'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.blPop', async cluster => {
|
testUtils.testWithCluster('cluster.blPop', async cluster => {
|
||||||
const [ blPopReply ] = await Promise.all([
|
const [ blPopReply ] = await Promise.all([
|
||||||
cluster.blPop(
|
cluster.blPop(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -75,5 +75,5 @@ describe('BLPOP', () => {
|
|||||||
element: 'element'
|
element: 'element'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
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 { transformArguments, transformReply } from './BRPOP';
|
||||||
import { commandOptions } from '../../index';
|
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([
|
const [ brPopReply ] = await Promise.all([
|
||||||
client.brPop(
|
client.brPop(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -56,9 +56,9 @@ describe('BRPOP', () => {
|
|||||||
element: 'element'
|
element: 'element'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.brPop', async cluster => {
|
testUtils.testWithCluster('cluster.brPop', async cluster => {
|
||||||
const [ brPopReply ] = await Promise.all([
|
const [ brPopReply ] = await Promise.all([
|
||||||
cluster.brPop(
|
cluster.brPop(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -75,5 +75,5 @@ describe('BRPOP', () => {
|
|||||||
element: 'element'
|
element: 'element'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
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 { transformArguments } from './BRPOPLPUSH';
|
||||||
import { commandOptions } from '../../index';
|
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([
|
const [ popReply ] = await Promise.all([
|
||||||
client.brPopLPush(
|
client.brPopLPush(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -26,9 +26,9 @@ describe('BRPOPLPUSH', () => {
|
|||||||
popReply,
|
popReply,
|
||||||
'element'
|
'element'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.brPopLPush', async cluster => {
|
testUtils.testWithCluster('cluster.brPopLPush', async cluster => {
|
||||||
const [ popReply ] = await Promise.all([
|
const [ popReply ] = await Promise.all([
|
||||||
cluster.brPopLPush(
|
cluster.brPopLPush(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -43,5 +43,5 @@ describe('BRPOPLPUSH', () => {
|
|||||||
popReply,
|
popReply,
|
||||||
'element'
|
'element'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './BZPOPMAX';
|
import { transformArguments, transformReply } from './BZPOPMAX';
|
||||||
import { commandOptions } from '../../index';
|
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([
|
const [ bzPopMaxReply ] = await Promise.all([
|
||||||
client.bzPopMax(
|
client.bzPopMax(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -61,5 +61,5 @@ describe('BZPOPMAX', () => {
|
|||||||
score: 1
|
score: 1
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './BZPOPMIN';
|
import { transformArguments, transformReply } from './BZPOPMIN';
|
||||||
import { commandOptions } from '../../index';
|
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([
|
const [ bzPopMinReply ] = await Promise.all([
|
||||||
client.bzPopMin(
|
client.bzPopMin(
|
||||||
commandOptions({ isolated: true }),
|
commandOptions({ isolated: true }),
|
||||||
@@ -61,5 +61,5 @@ describe('BZPOPMIN', () => {
|
|||||||
score: 1
|
score: 1
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './CLIENT_ID';
|
import { transformArguments } from './CLIENT_ID';
|
||||||
|
|
||||||
describe('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(
|
assert.equal(
|
||||||
typeof (await client.clientId()),
|
typeof (await client.clientId()),
|
||||||
'number'
|
'number'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -71,6 +71,6 @@ describe('CLUSTER SLOTS', () => {
|
|||||||
id: '58e6e48d41228013e5d9c1c37c5060693925e97e'
|
id: '58e6e48d41228013e5d9c1c37c5060693925e97e'
|
||||||
}]
|
}]
|
||||||
}]
|
}]
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { itWithClient, TestRedisServers } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './COMMAND';
|
import { transformArguments } from './COMMAND';
|
||||||
import { CommandCategories, CommandFlags } from './generic-transformers';
|
import { assertPingCommand } from './COMMAND_INFO.spec';
|
||||||
|
|
||||||
describe('COMMAND', () => {
|
describe('COMMAND', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
@@ -11,20 +11,7 @@ describe('COMMAND', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.command', async client => {
|
testUtils.testWithClient('client.command', async client => {
|
||||||
assert.deepEqual(
|
assertPingCommand((await client.command()).find(command => command.name === 'ping'));
|
||||||
(await client.command()).find(command => command.name === 'ping'),
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
{
|
|
||||||
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]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './COMMAND_COUNT';
|
import { transformArguments } from './COMMAND_COUNT';
|
||||||
|
|
||||||
describe('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(
|
assert.equal(
|
||||||
typeof await client.commandCount(),
|
typeof await client.commandCount(),
|
||||||
'number'
|
'number'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './COMMAND_GETKEYS';
|
import { transformArguments } from './COMMAND_GETKEYS';
|
||||||
|
|
||||||
describe('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(
|
assert.deepEqual(
|
||||||
await client.commandGetKeys(['GET', 'key']),
|
await client.commandGetKeys(['GET', 'key']),
|
||||||
['key']
|
['key']
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,26 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { itWithClient, TestRedisServers } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './COMMAND_INFO';
|
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', () => {
|
describe('COMMAND INFO', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
@@ -11,20 +30,7 @@ describe('COMMAND INFO', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.commandInfo', async client => {
|
testUtils.testWithClient('client.commandInfo', async client => {
|
||||||
assert.deepEqual(
|
assertPingCommand((await client.commandInfo(['PING']))[0]);
|
||||||
await client.commandInfo(['PING']),
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
[{
|
|
||||||
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]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './COPY';
|
import { transformArguments, transformReply } from './COPY';
|
||||||
|
|
||||||
describe('COPY', () => {
|
describe('COPY', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
@@ -58,10 +58,10 @@ describe('COPY', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.copy', async client => {
|
testUtils.testWithClient('client.copy', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.copy('source', 'destination'),
|
await client.copy('source', 'destination'),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './DBSIZE';
|
import { transformArguments } from './DBSIZE';
|
||||||
|
|
||||||
describe('DBSIZE', () => {
|
describe('DBSIZE', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('DBSIZE', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.dbSize', async client => {
|
testUtils.testWithClient('client.dbSize', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.dbSize(),
|
await client.dbSize(),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './DECR';
|
import { transformArguments } from './DECR';
|
||||||
|
|
||||||
describe('DECR', () => {
|
describe('DECR', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('DECR', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.decr', async client => {
|
testUtils.testWithClient('client.decr', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.decr('key'),
|
await client.decr('key'),
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './DECRBY';
|
import { transformArguments } from './DECRBY';
|
||||||
|
|
||||||
describe('DECRBY', () => {
|
describe('DECRBY', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('DECRBY', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.decrBy', async client => {
|
testUtils.testWithClient('client.decrBy', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.decrBy('key', 2),
|
await client.decrBy('key', 2),
|
||||||
-2
|
-2
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './DEL';
|
import { transformArguments } from './DEL';
|
||||||
|
|
||||||
describe('DEL', () => {
|
describe('DEL', () => {
|
||||||
@@ -19,10 +19,10 @@ describe('DEL', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.del', async client => {
|
testUtils.testWithClient('client.del', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.del('key'),
|
await client.del('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
|
||||||
describe('DUMP', () => {
|
describe('DUMP', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.dump', async client => {
|
testUtils.testWithClient('client.dump', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.dump('key'),
|
await client.dump('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './ECHO';
|
import { transformArguments } from './ECHO';
|
||||||
|
|
||||||
describe('ECHO', () => {
|
describe('ECHO', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('ECHO', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.echo', async client => {
|
testUtils.testWithClient('client.echo', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.echo('message'),
|
await client.echo('message'),
|
||||||
'message'
|
'message'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './EVAL';
|
import { transformArguments } from './EVAL';
|
||||||
|
|
||||||
describe('EVAL', () => {
|
describe('EVAL', () => {
|
||||||
@@ -13,17 +13,17 @@ describe('EVAL', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.eval', async client => {
|
testUtils.testWithClient('client.eval', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.eval('return 1'),
|
await client.eval('return 1'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.eval', async cluster => {
|
testUtils.testWithCluster('cluster.eval', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.eval('return 1'),
|
await cluster.eval('return 1'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './EXISTS';
|
import { transformArguments } from './EXISTS';
|
||||||
|
|
||||||
describe('EXISTS', () => {
|
describe('EXISTS', () => {
|
||||||
@@ -19,10 +19,10 @@ describe('EXISTS', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.exists', async client => {
|
testUtils.testWithClient('client.exists', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.exists('key'),
|
await client.exists('key'),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './EXPIRE';
|
import { transformArguments } from './EXPIRE';
|
||||||
|
|
||||||
describe('EXPIRE', () => {
|
describe('EXPIRE', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('EXPIRE', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.expire', async client => {
|
testUtils.testWithClient('client.expire', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.expire('key', 0),
|
await client.expire('key', 0),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './EXPIREAT';
|
import { transformArguments } from './EXPIREAT';
|
||||||
|
|
||||||
describe('EXPIREAT', () => {
|
describe('EXPIREAT', () => {
|
||||||
@@ -20,10 +20,10 @@ describe('EXPIREAT', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.expireAt', async client => {
|
testUtils.testWithClient('client.expireAt', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.expireAt('key', 1),
|
await client.expireAt('key', 1),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { RedisFlushModes, transformArguments } from './FLUSHALL';
|
import { RedisFlushModes, transformArguments } from './FLUSHALL';
|
||||||
|
|
||||||
describe('FLUSHALL', () => {
|
describe('FLUSHALL', () => {
|
||||||
@@ -26,10 +26,10 @@ describe('FLUSHALL', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.flushAll', async client => {
|
testUtils.testWithClient('client.flushAll', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.flushAll(),
|
await client.flushAll(),
|
||||||
'OK'
|
'OK'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { RedisFlushModes } from './FLUSHALL';
|
import { RedisFlushModes } from './FLUSHALL';
|
||||||
import { transformArguments } from './FLUSHDB';
|
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(
|
assert.equal(
|
||||||
await client.flushDb(),
|
await client.flushDb(),
|
||||||
'OK'
|
'OK'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GEOADD';
|
import { transformArguments } from './GEOADD';
|
||||||
|
|
||||||
describe('GEOADD', () => {
|
describe('GEOADD', () => {
|
||||||
@@ -71,7 +71,7 @@ describe('GEOADD', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.geoAdd', async client => {
|
testUtils.testWithClient('client.geoAdd', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.geoAdd('key', {
|
await client.geoAdd('key', {
|
||||||
member: 'member',
|
member: 'member',
|
||||||
@@ -80,9 +80,9 @@ describe('GEOADD', () => {
|
|||||||
}),
|
}),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoAdd', async cluster => {
|
testUtils.testWithCluster('cluster.geoAdd', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.geoAdd('key', {
|
await cluster.geoAdd('key', {
|
||||||
member: 'member',
|
member: 'member',
|
||||||
@@ -91,5 +91,5 @@ describe('GEOADD', () => {
|
|||||||
}),
|
}),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GEODIST';
|
import { transformArguments } from './GEODIST';
|
||||||
|
|
||||||
describe('GEODIST', () => {
|
describe('GEODIST', () => {
|
||||||
@@ -20,14 +20,14 @@ describe('GEODIST', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('client.geoDist', () => {
|
describe('client.geoDist', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'null', async client => {
|
testUtils.testWithClient('null', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.geoDist('key', '1', '2'),
|
await client.geoDist('key', '1', '2'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'with value', async client => {
|
testUtils.testWithClient('with value', async client => {
|
||||||
const [, dist] = await Promise.all([
|
const [, dist] = await Promise.all([
|
||||||
client.geoAdd('key', [{
|
client.geoAdd('key', [{
|
||||||
member: '1',
|
member: '1',
|
||||||
@@ -45,13 +45,13 @@ describe('GEODIST', () => {
|
|||||||
dist,
|
dist,
|
||||||
157270.0561
|
157270.0561
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoDist', async cluster => {
|
testUtils.testWithCluster('cluster.geoDist', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.geoDist('key', '1', '2'),
|
await cluster.geoDist('key', '1', '2'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GEOHASH';
|
import { transformArguments } from './GEOHASH';
|
||||||
|
|
||||||
describe('GEOHASH', () => {
|
describe('GEOHASH', () => {
|
||||||
@@ -19,17 +19,17 @@ describe('GEOHASH', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.geoHash', async client => {
|
testUtils.testWithClient('client.geoHash', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.geoHash('key', 'member'),
|
await client.geoHash('key', 'member'),
|
||||||
[null]
|
[null]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoHash', async cluster => {
|
testUtils.testWithCluster('cluster.geoHash', async cluster => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await cluster.geoHash('key', 'member'),
|
await cluster.geoHash('key', 'member'),
|
||||||
[null]
|
[null]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments, transformReply } from './GEOPOS';
|
||||||
|
|
||||||
describe('GEOPOS', () => {
|
describe('GEOPOS', () => {
|
||||||
@@ -39,14 +39,14 @@ describe('GEOPOS', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('client.geoPos', () => {
|
describe('client.geoPos', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'null', async client => {
|
testUtils.testWithClient('null', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.geoPos('key', 'member'),
|
await client.geoPos('key', 'member'),
|
||||||
[null]
|
[null]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'with member', async client => {
|
testUtils.testWithClient('with member', async client => {
|
||||||
const coordinates = {
|
const coordinates = {
|
||||||
longitude: '-122.06429868936538696',
|
longitude: '-122.06429868936538696',
|
||||||
latitude: '37.37749628831998194'
|
latitude: '37.37749628831998194'
|
||||||
@@ -61,13 +61,13 @@ describe('GEOPOS', () => {
|
|||||||
await client.geoPos('key', 'member'),
|
await client.geoPos('key', 'member'),
|
||||||
[coordinates]
|
[coordinates]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoPos', async cluster => {
|
testUtils.testWithCluster('cluster.geoPos', async cluster => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await cluster.geoPos('key', 'member'),
|
await cluster.geoPos('key', 'member'),
|
||||||
[null]
|
[null]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './GEOSEARCH';
|
||||||
|
|
||||||
describe('GEOSEARCH', () => {
|
describe('GEOSEARCH', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -15,7 +15,7 @@ describe('GEOSEARCH', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.geoSearch', async client => {
|
testUtils.testWithClient('client.geoSearch', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.geoSearch('key', 'member', {
|
await client.geoSearch('key', 'member', {
|
||||||
radius: 1,
|
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(
|
assert.deepEqual(
|
||||||
await cluster.geoSearch('key', 'member', {
|
await cluster.geoSearch('key', 'member', {
|
||||||
radius: 1,
|
radius: 1,
|
||||||
@@ -33,5 +33,5 @@ describe('GEOSEARCH', () => {
|
|||||||
}),
|
}),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments, transformReply } from './GEOSEARCHSTORE';
|
||||||
|
|
||||||
describe('GEOSEARCHSTORE', () => {
|
describe('GEOSEARCHSTORE', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
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', {
|
await client.geoAdd('source', {
|
||||||
longitude: 1,
|
longitude: 1,
|
||||||
latitude: 1,
|
latitude: 1,
|
||||||
@@ -61,9 +61,9 @@ describe('GEOSEARCHSTORE', () => {
|
|||||||
}),
|
}),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoSearchStore', async cluster => {
|
testUtils.testWithCluster('cluster.geoSearchStore', async cluster => {
|
||||||
await cluster.geoAdd('{tag}source', {
|
await cluster.geoAdd('{tag}source', {
|
||||||
longitude: 1,
|
longitude: 1,
|
||||||
latitude: 1,
|
latitude: 1,
|
||||||
@@ -77,5 +77,5 @@ describe('GEOSEARCHSTORE', () => {
|
|||||||
}),
|
}),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { RedisCommandArguments } from '.';
|
import { RedisCommandArguments } from '.';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster, describeHandleMinimumRedisVersion } from '../test-utils';
|
|
||||||
import { GeoReplyWith } from './generic-transformers';
|
import { GeoReplyWith } from './generic-transformers';
|
||||||
import { transformArguments } from './GEOSEARCH_WITH';
|
import { transformArguments } from './GEOSEARCH_WITH';
|
||||||
|
|
||||||
describe('GEOSEARCH WITH', () => {
|
describe('GEOSEARCH WITH', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
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'];
|
expectedReply.preserve = ['WITHDIST'];
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -20,7 +20,7 @@ describe('GEOSEARCH WITH', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.geoSearchWith', async client => {
|
testUtils.testWithClient('client.geoSearchWith', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.geoSearchWith('key', 'member', {
|
await client.geoSearchWith('key', 'member', {
|
||||||
radius: 1,
|
radius: 1,
|
||||||
@@ -28,9 +28,9 @@ describe('GEOSEARCH WITH', () => {
|
|||||||
}, [GeoReplyWith.DISTANCE]),
|
}, [GeoReplyWith.DISTANCE]),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.geoSearchWith', async cluster => {
|
testUtils.testWithCluster('cluster.geoSearchWith', async cluster => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await cluster.geoSearchWith('key', 'member', {
|
await cluster.geoSearchWith('key', 'member', {
|
||||||
radius: 1,
|
radius: 1,
|
||||||
@@ -38,5 +38,5 @@ describe('GEOSEARCH WITH', () => {
|
|||||||
}, [GeoReplyWith.DISTANCE]),
|
}, [GeoReplyWith.DISTANCE]),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GET';
|
import { transformArguments } from './GET';
|
||||||
|
|
||||||
describe('GET', () => {
|
describe('GET', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('GET', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.get', async client => {
|
testUtils.testWithClient('client.get', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.get('key'),
|
await client.get('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.get', async cluster => {
|
testUtils.testWithCluster('cluster.get', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.get('key'),
|
await cluster.get('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GETBIT';
|
import { transformArguments } from './GETBIT';
|
||||||
|
|
||||||
describe('GETBIT', () => {
|
describe('GETBIT', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('GETBIT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getBit', async client => {
|
testUtils.testWithClient('client.getBit', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.getBit('key', 0),
|
await client.getBit('key', 0),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.getBit', async cluster => {
|
testUtils.testWithCluster('cluster.getBit', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.getBit('key', 0),
|
await cluster.getBit('key', 0),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './GETDEL';
|
||||||
|
|
||||||
describe('GETDEL', () => {
|
describe('GETDEL', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,18 +12,17 @@ describe('GETDEL', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getDel', async client => {
|
testUtils.testWithClient('client.getDel', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.getDel('key'),
|
await client.getDel('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
|
testUtils.testWithCluster('cluster.getDel', async cluster => {
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.getDel', async cluster => {
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.getDel('key'),
|
await cluster.getDel('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './GETEX';
|
||||||
|
|
||||||
describe('GETEX', () => {
|
describe('GETEX', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('EX', () => {
|
it('EX', () => {
|
||||||
@@ -76,21 +76,21 @@ describe('GETEX', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getEx', async client => {
|
testUtils.testWithClient('client.getEx', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.getEx('key', {
|
await client.getEx('key', {
|
||||||
PERSIST: true
|
PERSIST: true
|
||||||
}),
|
}),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.getEx', async cluster => {
|
testUtils.testWithCluster('cluster.getEx', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.getEx('key', {
|
await cluster.getEx('key', {
|
||||||
PERSIST: true
|
PERSIST: true
|
||||||
}),
|
}),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GETRANGE';
|
import { transformArguments } from './GETRANGE';
|
||||||
|
|
||||||
describe('GETRANGE', () => {
|
describe('GETRANGE', () => {
|
||||||
@@ -10,18 +10,17 @@ describe('GETRANGE', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getRange', async client => {
|
testUtils.testWithClient('client.getRange', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.getRange('key', 0, -1),
|
await client.getRange('key', 0, -1),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
|
testUtils.testWithCluster('cluster.lTrim', async cluster => {
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lTrim', async cluster => {
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.getRange('key', 0, -1),
|
await cluster.getRange('key', 0, -1),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './GETSET';
|
import { transformArguments } from './GETSET';
|
||||||
|
|
||||||
describe('GETSET', () => {
|
describe('GETSET', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('GETSET', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getSet', async client => {
|
testUtils.testWithClient('client.getSet', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.getSet('key', 'value'),
|
await client.getSet('key', 'value'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.getSet', async cluster => {
|
testUtils.testWithCluster('cluster.getSet', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.getSet('key', 'value'),
|
await cluster.getSet('key', 'value'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,22 +1,22 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
|
||||||
describe('GET_BUFFER', () => {
|
describe('GET_BUFFER', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.getBuffer', async client => {
|
testUtils.testWithClient('client.getBuffer', async client => {
|
||||||
const buffer = Buffer.from('string');
|
const buffer = Buffer.from('string');
|
||||||
await client.set('key', buffer);
|
await client.set('key', buffer);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
buffer,
|
buffer,
|
||||||
await client.getBuffer('key')
|
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');
|
const buffer = Buffer.from('string');
|
||||||
await cluster.set('key', buffer);
|
await cluster.set('key', buffer);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
buffer,
|
buffer,
|
||||||
await cluster.getBuffer('key')
|
await cluster.getBuffer('key')
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HDEL';
|
import { transformArguments } from './HDEL';
|
||||||
|
|
||||||
describe('HDEL', () => {
|
describe('HDEL', () => {
|
||||||
@@ -19,10 +19,10 @@ describe('HDEL', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hDel', async client => {
|
testUtils.testWithClient('client.hDel', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hDel('key', 'field'),
|
await client.hDel('key', 'field'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './HELLO';
|
||||||
|
|
||||||
describe('HELLO', () => {
|
describe('HELLO', () => {
|
||||||
describeHandleMinimumRedisVersion([6]);
|
testUtils.isVersionGreaterThanHook([6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
@@ -60,20 +60,17 @@ describe('HELLO', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hello', async client => {
|
testUtils.testWithClient('client.hello', async client => {
|
||||||
assert.deepEqual(
|
const reply = await client.hello();
|
||||||
await client.hello(),
|
assert.equal(reply.server, 'redis');
|
||||||
{
|
assert.equal(typeof reply.version, 'string');
|
||||||
server: 'redis',
|
assert.equal(reply.proto, 2);
|
||||||
version: REDIS_VERSION.join('.'),
|
assert.equal(typeof reply.id, 'number');
|
||||||
proto: 2,
|
assert.equal(reply.mode, 'standalone');
|
||||||
id: await client.clientId(),
|
assert.equal(reply.role, 'master');
|
||||||
mode: 'standalone',
|
assert.deepEqual(reply.modules, []);
|
||||||
role: 'master',
|
|
||||||
modules: []
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}, {
|
}, {
|
||||||
minimumRedisVersion: [6, 2]
|
...GLOBAL.SERVERS.OPEN,
|
||||||
|
minimumDockerVersion: [6, 2]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HEXISTS';
|
import { transformArguments } from './HEXISTS';
|
||||||
|
|
||||||
describe('HEXISTS', () => {
|
describe('HEXISTS', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HEXISTS', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hExists', async client => {
|
testUtils.testWithClient('client.hExists', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hExists('key', 'field'),
|
await client.hExists('key', 'field'),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HGET';
|
import { transformArguments } from './HGET';
|
||||||
|
|
||||||
describe('HGET', () => {
|
describe('HGET', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HGET', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hGet', async client => {
|
testUtils.testWithClient('client.hGet', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hGet('key', 'field'),
|
await client.hGet('key', 'field'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformReply } from './HGETALL';
|
import { transformReply } from './HGETALL';
|
||||||
|
|
||||||
describe('HGETALL', () => {
|
describe('HGETALL', () => {
|
||||||
@@ -32,10 +32,10 @@ describe('HGETALL', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hGetAll', async client => {
|
testUtils.testWithClient('client.hGetAll', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hGetAll('key'),
|
await client.hGetAll('key'),
|
||||||
Object.create(null)
|
Object.create(null)
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HINCRBY';
|
import { transformArguments } from './HINCRBY';
|
||||||
|
|
||||||
describe('HINCRBY', () => {
|
describe('HINCRBY', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HINCRBY', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hIncrBy', async client => {
|
testUtils.testWithClient('client.hIncrBy', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hIncrBy('key', 'field', 1),
|
await client.hIncrBy('key', 'field', 1),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HINCRBYFLOAT';
|
import { transformArguments } from './HINCRBYFLOAT';
|
||||||
|
|
||||||
describe('HINCRBYFLOAT', () => {
|
describe('HINCRBYFLOAT', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HINCRBYFLOAT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hIncrByFloat', async client => {
|
testUtils.testWithClient('client.hIncrByFloat', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hIncrByFloat('key', 'field', 1.5),
|
await client.hIncrByFloat('key', 'field', 1.5),
|
||||||
'1.5'
|
'1.5'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HKEYS';
|
import { transformArguments } from './HKEYS';
|
||||||
|
|
||||||
describe('HKEYS', () => {
|
describe('HKEYS', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HKEYS', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hKeys', async client => {
|
testUtils.testWithClient('client.hKeys', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hKeys('key'),
|
await client.hKeys('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HLEN';
|
import { transformArguments } from './HLEN';
|
||||||
|
|
||||||
describe('HLEN', () => {
|
describe('HLEN', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HLEN', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hLen', async client => {
|
testUtils.testWithClient('client.hLen', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hLen('key'),
|
await client.hLen('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HMGET';
|
import { transformArguments } from './HMGET';
|
||||||
|
|
||||||
describe('HMGET', () => {
|
describe('HMGET', () => {
|
||||||
@@ -19,10 +19,10 @@ describe('HMGET', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hmGet', async client => {
|
testUtils.testWithClient('client.hmGet', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hmGet('key', 'field'),
|
await client.hmGet('key', 'field'),
|
||||||
[null]
|
[null]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HRANDFIELD';
|
import { transformArguments } from './HRANDFIELD';
|
||||||
|
|
||||||
describe('HRANDFIELD', () => {
|
describe('HRANDFIELD', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,10 +12,10 @@ describe('HRANDFIELD', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hRandField', async client => {
|
testUtils.testWithClient('client.hRandField', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hRandField('key'),
|
await client.hRandField('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, describeHandleMinimumRedisVersion } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HRANDFIELD_COUNT';
|
import { transformArguments } from './HRANDFIELD_COUNT';
|
||||||
|
|
||||||
describe('HRANDFIELD COUNT', () => {
|
describe('HRANDFIELD COUNT', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2, 5]);
|
testUtils.isVersionGreaterThanHook([6, 2, 5]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,10 +12,10 @@ describe('HRANDFIELD COUNT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hRandFieldCount', async client => {
|
testUtils.testWithClient('client.hRandFieldCount', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hRandFieldCount('key', 1),
|
await client.hRandFieldCount('key', 1),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './HRANDFIELD_COUNT_WITHVALUES';
|
||||||
|
|
||||||
describe('HRANDFIELD COUNT WITHVALUES', () => {
|
describe('HRANDFIELD COUNT WITHVALUES', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2, 5]);
|
testUtils.isVersionGreaterThanHook([6, 2, 5]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
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(
|
assert.deepEqual(
|
||||||
await client.hRandFieldCountWithValues('key', 1),
|
await client.hRandFieldCountWithValues('key', 1),
|
||||||
Object.create(null)
|
Object.create(null)
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments, transformReply } from './HSCAN';
|
import { transformArguments, transformReply } from './HSCAN';
|
||||||
|
|
||||||
describe('HSCAN', () => {
|
describe('HSCAN', () => {
|
||||||
@@ -65,7 +65,7 @@ describe('HSCAN', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hScan', async client => {
|
testUtils.testWithClient('client.hScan', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hScan('key', 0),
|
await client.hScan('key', 0),
|
||||||
{
|
{
|
||||||
@@ -73,5 +73,5 @@ describe('HSCAN', () => {
|
|||||||
tuples: []
|
tuples: []
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './HSET';
|
import { transformArguments } from './HSET';
|
||||||
import { TestRedisServers, itWithClient, TestRedisClusters, itWithCluster } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
|
||||||
describe('HSET', () => {
|
describe('HSET', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
@@ -33,17 +33,17 @@ describe('HSET', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hSet', async client => {
|
testUtils.testWithClient('client.hSet', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hSet('key', 'field', 'value'),
|
await client.hSet('key', 'field', 'value'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.hSet', async cluster => {
|
testUtils.testWithCluster('cluster.hSet', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.hSet('key', { field: 'value' }),
|
await cluster.hSet('key', { field: 'value' }),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HSETNX';
|
import { transformArguments } from './HSETNX';
|
||||||
|
|
||||||
describe('HSETNX', () => {
|
describe('HSETNX', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HSETNX', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hSetNX', async client => {
|
testUtils.testWithClient('client.hSetNX', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hSetNX('key', 'field', 'value'),
|
await client.hSetNX('key', 'field', 'value'),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HSTRLEN';
|
import { transformArguments } from './HSTRLEN';
|
||||||
|
|
||||||
describe('HSTRLEN', () => {
|
describe('HSTRLEN', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HSTRLEN', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hStrLen', async client => {
|
testUtils.testWithClient('client.hStrLen', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.hStrLen('key', 'field'),
|
await client.hStrLen('key', 'field'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './HVALS';
|
import { transformArguments } from './HVALS';
|
||||||
|
|
||||||
describe('HVALS', () => {
|
describe('HVALS', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('HVALS', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.hVals', async client => {
|
testUtils.testWithClient('client.hVals', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.hVals('key'),
|
await client.hVals('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './INCR';
|
import { transformArguments } from './INCR';
|
||||||
|
|
||||||
describe('INCR', () => {
|
describe('INCR', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('INCR', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.incr', async client => {
|
testUtils.testWithClient('client.incr', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.incr('key'),
|
await client.incr('key'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './INCRBY';
|
import { transformArguments } from './INCRBY';
|
||||||
|
|
||||||
describe('INCR', () => {
|
describe('INCR', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('INCR', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.incrBy', async client => {
|
testUtils.testWithClient('client.incrBy', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.incrBy('key', 1),
|
await client.incrBy('key', 1),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './INCRBYFLOAT';
|
import { transformArguments } from './INCRBYFLOAT';
|
||||||
|
|
||||||
describe('INCRBYFLOAT', () => {
|
describe('INCRBYFLOAT', () => {
|
||||||
@@ -10,10 +10,10 @@ describe('INCRBYFLOAT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.incrByFloat', async client => {
|
testUtils.testWithClient('client.incrByFloat', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.incrByFloat('key', 1.5),
|
await client.incrByFloat('key', 1.5),
|
||||||
'1.5'
|
'1.5'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
|
|
||||||
describe('KEYS', () => {
|
describe('KEYS', () => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.keys', async client => {
|
testUtils.testWithClient('client.keys', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.keys('pattern'),
|
await client.keys('pattern'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LASTSAVE';
|
import { transformArguments } from './LASTSAVE';
|
||||||
|
|
||||||
describe('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);
|
assert.ok((await client.lastSave()) instanceof Date);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LINDEX';
|
import { transformArguments } from './LINDEX';
|
||||||
|
|
||||||
describe('LINDEX', () => {
|
describe('LINDEX', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('LINDEX', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lIndex', async client => {
|
testUtils.testWithClient('client.lIndex', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lIndex('key', 'element'),
|
await client.lIndex('key', 'element'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lIndex', async cluster => {
|
testUtils.testWithCluster('cluster.lIndex', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lIndex('key', 'element'),
|
await cluster.lIndex('key', 'element'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LINSERT';
|
import { transformArguments } from './LINSERT';
|
||||||
|
|
||||||
describe('LINSERT', () => {
|
describe('LINSERT', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('LINSERT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lInsert', async client => {
|
testUtils.testWithClient('client.lInsert', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
await client.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lLen', async cluster => {
|
testUtils.testWithCluster('cluster.lLen', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
await cluster.lInsert('key', 'BEFORE', 'pivot', 'element'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LLEN';
|
import { transformArguments } from './LLEN';
|
||||||
|
|
||||||
describe('LLEN', () => {
|
describe('LLEN', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('LLEN', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lLen', async client => {
|
testUtils.testWithClient('client.lLen', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lLen('key'),
|
await client.lLen('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lLen', async cluster => {
|
testUtils.testWithCluster('cluster.lLen', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lLen('key'),
|
await cluster.lLen('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './LMOVE';
|
||||||
|
|
||||||
describe('LMOVE', () => {
|
describe('LMOVE', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,17 +12,17 @@ describe('LMOVE', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lMove', async client => {
|
testUtils.testWithClient('client.lMove', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
|
await client.lMove('source', 'destination', 'LEFT', 'RIGHT'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lMove', async cluster => {
|
testUtils.testWithCluster('cluster.lMove', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT'),
|
await cluster.lMove('{tag}source', '{tag}destination', 'LEFT', 'RIGHT'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LOLWUT';
|
import { transformArguments } from './LOLWUT';
|
||||||
|
|
||||||
describe('LOLWUT', () => {
|
describe('LOLWUT', () => {
|
||||||
@@ -26,11 +26,10 @@ describe('LOLWUT', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUtils.testWithClient('client.LOLWUT', async client => {
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.LOLWUT', async client => {
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
typeof (await client.LOLWUT()),
|
typeof (await client.LOLWUT()),
|
||||||
'string'
|
'string'
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LPOP';
|
import { transformArguments } from './LPOP';
|
||||||
|
|
||||||
describe('LPOP', () => {
|
describe('LPOP', () => {
|
||||||
@@ -10,17 +10,17 @@ describe('LPOP', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lPop', async client => {
|
testUtils.testWithClient('client.lPop', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lPop('key'),
|
await client.lPop('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPop', async cluster => {
|
testUtils.testWithCluster('cluster.lPop', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lPop('key'),
|
await cluster.lPop('key'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './LPOP_COUNT';
|
||||||
|
|
||||||
describe('LPOP COUNT', () => {
|
describe('LPOP COUNT', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -12,17 +12,17 @@ describe('LPOP COUNT', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lPopCount', async client => {
|
testUtils.testWithClient('client.lPopCount', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lPopCount('key', 1),
|
await client.lPopCount('key', 1),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPop', async cluster => {
|
testUtils.testWithCluster('cluster.lPopCount', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lPopCount('key', 1),
|
await cluster.lPopCount('key', 1),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './LPOS';
|
||||||
|
|
||||||
describe('LPOS', () => {
|
describe('LPOS', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 0, 6]);
|
testUtils.isVersionGreaterThanHook([6, 0, 6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
@@ -42,17 +42,17 @@ describe('LPOS', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lPos', async client => {
|
testUtils.testWithClient('client.lPos', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lPos('key', 'element'),
|
await client.lPos('key', 'element'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPos', async cluster => {
|
testUtils.testWithCluster('cluster.lPos', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lPos('key', 'element'),
|
await cluster.lPos('key', 'element'),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { strict as assert } from 'assert';
|
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';
|
import { transformArguments } from './LPOS_COUNT';
|
||||||
|
|
||||||
describe('LPOS COUNT', () => {
|
describe('LPOS COUNT', () => {
|
||||||
describeHandleMinimumRedisVersion([6, 0, 6]);
|
testUtils.isVersionGreaterThanHook([6, 0, 6]);
|
||||||
|
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
@@ -42,17 +42,17 @@ describe('LPOS COUNT', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lPosCount', async client => {
|
testUtils.testWithClient('client.lPosCount', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.lPosCount('key', 'element', 0),
|
await client.lPosCount('key', 'element', 0),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPosCount', async cluster => {
|
testUtils.testWithCluster('cluster.lPosCount', async cluster => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await cluster.lPosCount('key', 'element', 0),
|
await cluster.lPosCount('key', 'element', 0),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './LPUSH';
|
import { transformArguments } from './LPUSH';
|
||||||
|
|
||||||
describe('LPUSH', () => {
|
describe('LPUSH', () => {
|
||||||
@@ -19,17 +19,17 @@ describe('LPUSH', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
itWithClient(TestRedisServers.OPEN, 'client.lPush', async client => {
|
testUtils.testWithClient('client.lPush', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.lPush('key', 'field'),
|
await client.lPush('key', 'field'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.SERVERS.OPEN);
|
||||||
|
|
||||||
itWithCluster(TestRedisClusters.OPEN, 'cluster.lPush', async cluster => {
|
testUtils.testWithCluster('cluster.lPush', async cluster => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await cluster.lPush('key', 'field'),
|
await cluster.lPush('key', 'field'),
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
});
|
}, GLOBAL.CLUSTERS.OPEN);
|
||||||
});
|
});
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user