1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

V5 bringing RESP3, Sentinel and TypeMapping to node-redis

RESP3 Support
   - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion.
 
Sentinel

TypeMapping

Correctly types Multi commands

Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
Shaya Potter
2024-10-15 17:46:52 +03:00
committed by GitHub
parent 2fc79bdfb3
commit b2d35c5286
1174 changed files with 45931 additions and 36274 deletions

View File

@@ -1,96 +1,99 @@
import { strict as assert } from 'assert';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SORT';
import SORT from './SORT';
describe('SORT', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key'),
['SORT', 'key']
);
});
it('with BY', () => {
assert.deepEqual(
transformArguments('key', {
BY: 'pattern'
}),
['SORT', 'key', 'BY', 'pattern']
);
});
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('key', {
LIMIT: {
offset: 0,
count: 1
}
}),
['SORT', 'key', 'LIMIT', '0', '1']
);
});
describe('with GET', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', {
GET: 'pattern'
}),
['SORT', 'key', 'GET', 'pattern']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', {
GET: ['1', '2']
}),
['SORT', 'key', 'GET', '1', 'GET', '2']
);
});
});
it('with DIRECTION', () => {
assert.deepEqual(
transformArguments('key', {
DIRECTION: 'ASC'
}),
['SORT', 'key', 'ASC']
);
});
it('with ALPHA', () => {
assert.deepEqual(
transformArguments('key', {
ALPHA: true
}),
['SORT', 'key', 'ALPHA']
);
});
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
assert.deepEqual(
transformArguments('key', {
BY: 'pattern',
LIMIT: {
offset: 0,
count: 1
},
GET: 'pattern',
DIRECTION: 'ASC',
ALPHA: true
}),
['SORT', 'key', 'BY', 'pattern', 'LIMIT', '0', '1', 'GET', 'pattern', 'ASC', 'ALPHA']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
SORT.transformArguments('key'),
['SORT', 'key']
);
});
testUtils.testWithClient('client.sort', async client => {
it('with BY', () => {
assert.deepEqual(
SORT.transformArguments('key', {
BY: 'pattern'
}),
['SORT', 'key', 'BY', 'pattern']
);
});
it('with LIMIT', () => {
assert.deepEqual(
SORT.transformArguments('key', {
LIMIT: {
offset: 0,
count: 1
}
}),
['SORT', 'key', 'LIMIT', '0', '1']
);
});
describe('with GET', () => {
it('string', () => {
assert.deepEqual(
await client.sort('key'),
[]
SORT.transformArguments('key', {
GET: 'pattern'
}),
['SORT', 'key', 'GET', 'pattern']
);
}, GLOBAL.SERVERS.OPEN);
});
it('array', () => {
assert.deepEqual(
SORT.transformArguments('key', {
GET: ['1', '2']
}),
['SORT', 'key', 'GET', '1', 'GET', '2']
);
});
});
it('with DIRECTION', () => {
assert.deepEqual(
SORT.transformArguments('key', {
DIRECTION: 'ASC'
}),
['SORT', 'key', 'ASC']
);
});
it('with ALPHA', () => {
assert.deepEqual(
SORT.transformArguments('key', {
ALPHA: true
}),
['SORT', 'key', 'ALPHA']
);
});
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
assert.deepEqual(
SORT.transformArguments('key', {
BY: 'pattern',
LIMIT: {
offset: 0,
count: 1
},
GET: 'pattern',
DIRECTION: 'ASC',
ALPHA: true
}),
['SORT', 'key', 'BY', 'pattern', 'LIMIT', '0', '1', 'GET', 'pattern', 'ASC', 'ALPHA']
);
});
});
testUtils.testAll('sort', async client => {
assert.deepEqual(
await client.sort('key'),
[]
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});