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