You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-10 11:43:01 +03:00
clean some tests
This commit is contained in:
@@ -339,24 +339,18 @@ describe('Client', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with script', async () => {
|
itWithClient(TestRedisServers.OPEN, 'with script', async client => {
|
||||||
const client = RedisClient.create({
|
|
||||||
scripts: {
|
|
||||||
square: SQUARE_SCRIPT
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await client.connect();
|
|
||||||
|
|
||||||
try {
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.multi()
|
await client.multi()
|
||||||
.square(2)
|
.square(2)
|
||||||
.exec(),
|
.exec(),
|
||||||
[4]
|
[4]
|
||||||
);
|
);
|
||||||
} finally {
|
}, {
|
||||||
await client.disconnect();
|
clientOptions: {
|
||||||
|
scripts: {
|
||||||
|
square: SQUARE_SCRIPT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -389,27 +383,26 @@ describe('Client', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scripts', async () => {
|
itWithClient(TestRedisServers.OPEN, 'scripts', async client => {
|
||||||
const client = RedisClient.create({
|
|
||||||
scripts: {
|
|
||||||
square: SQUARE_SCRIPT
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
await client.connect();
|
|
||||||
|
|
||||||
try {
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.square(2),
|
await client.square(2),
|
||||||
4
|
4
|
||||||
);
|
);
|
||||||
} finally {
|
}, {
|
||||||
await client.disconnect();
|
clientOptions: {
|
||||||
|
scripts: {
|
||||||
|
square: SQUARE_SCRIPT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('modules', async () => {
|
itWithClient(TestRedisServers.OPEN, 'modules', async client => {
|
||||||
const client = RedisClient.create({
|
assert.equal(
|
||||||
|
await client.module.echo('message'),
|
||||||
|
'message'
|
||||||
|
);
|
||||||
|
}, {
|
||||||
|
clientOptions: {
|
||||||
modules: {
|
modules: {
|
||||||
module: {
|
module: {
|
||||||
echo: {
|
echo: {
|
||||||
@@ -422,17 +415,6 @@ describe('Client', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
await client.connect();
|
|
||||||
|
|
||||||
try {
|
|
||||||
assert.equal(
|
|
||||||
await client.module.echo('message'),
|
|
||||||
'message'
|
|
||||||
);
|
|
||||||
} finally {
|
|
||||||
await client.disconnect();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -52,13 +52,13 @@ export enum TestRedisServers {
|
|||||||
PASSWORD
|
PASSWORD
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TEST_REDIS_SERVERS: Record<TestRedisServers, RedisClientOptions<RedisModules, RedisScripts>> = <any>{};
|
export const TEST_REDIS_SERVERS: Record<TestRedisServers, Omit<RedisClientOptions<RedisModules, RedisScripts>, 'modules' | 'scripts'>> = <any>{};
|
||||||
|
|
||||||
export enum TestRedisClusters {
|
export enum TestRedisClusters {
|
||||||
OPEN
|
OPEN
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TEST_REDIS_CLUSTERES: Record<TestRedisClusters, RedisClusterOptions<RedisModules, RedisScripts>> = <any>{};
|
export const TEST_REDIS_CLUSTERES: Record<TestRedisClusters, Omit<RedisClusterOptions<RedisModules, RedisScripts>, 'modules' | 'scripts'>> = <any>{};
|
||||||
|
|
||||||
let port = 6379;
|
let port = 6379;
|
||||||
|
|
||||||
@@ -284,15 +284,15 @@ export function describeHandleMinimumRedisVersion(minimumVersion: PartialRedisVe
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RedisClientTestOptions extends RedisTestOptions {
|
interface RedisClientTestOptions<M extends RedisModules, S extends RedisScripts> extends RedisTestOptions {
|
||||||
clientOptions?: RedisClientOptions<{}, {}>;
|
clientOptions?: RedisClientOptions<M, S>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function itWithClient(
|
export function itWithClient<M extends RedisModules, S extends RedisScripts>(
|
||||||
type: TestRedisServers,
|
type: TestRedisServers,
|
||||||
title: string,
|
title: string,
|
||||||
fn: (client: RedisClientType) => Promise<void>,
|
fn: (client: RedisClientType<M, S>) => Promise<void>,
|
||||||
options?: RedisClientTestOptions
|
options?: RedisClientTestOptions<M, S>
|
||||||
): void {
|
): void {
|
||||||
it(title, async function () {
|
it(title, async function () {
|
||||||
if (handleMinimumRedisVersion(this, options?.minimumRedisVersion)) return;
|
if (handleMinimumRedisVersion(this, options?.minimumRedisVersion)) return;
|
||||||
|
Reference in New Issue
Block a user