You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
* Parser support with all commands * remove "dist" from all imports for consistency * address most of my review comments * small tweak to multi type mapping handling * tweak multi commands / fix addScript cases * nits * addressed all in person review comments * revert addCommand/addScript changes to multi-commands addCommand needs to be there for sendCommand like ability within a multi. If its there, it might as well be used by createCommand() et al, to avoid repeating code. addScript is there (even though only used once), but now made private to keep the logic for bookkeeping near each other.
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import { strict as assert } from 'node:assert';
|
|
import { TIME_SERIES_DUPLICATE_POLICIES } from '.';
|
|
import testUtils, { GLOBAL } from '../test-utils';
|
|
import INFO, { InfoReply } from './INFO';
|
|
import { TIME_SERIES_AGGREGATION_TYPE } from './CREATERULE';
|
|
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
|
|
|
|
describe('TS.INFO', () => {
|
|
it('transformArguments', () => {
|
|
assert.deepEqual(
|
|
parseArgs(INFO, 'key'),
|
|
['TS.INFO', 'key']
|
|
);
|
|
});
|
|
|
|
testUtils.testWithClient('client.ts.info', async client => {
|
|
await Promise.all([
|
|
client.ts.create('key', {
|
|
LABELS: { id: '1' },
|
|
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.LAST
|
|
}),
|
|
client.ts.create('key2'),
|
|
client.ts.createRule('key', 'key2', TIME_SERIES_AGGREGATION_TYPE.COUNT, 5),
|
|
client.ts.add('key', 1, 10)
|
|
]);
|
|
|
|
assertInfo(await client.ts.info('key') as any);
|
|
}, GLOBAL.SERVERS.OPEN);
|
|
});
|
|
|
|
export function assertInfo(info: InfoReply): void {
|
|
assert.equal(typeof info.totalSamples, 'number');
|
|
assert.equal(typeof info.memoryUsage, 'number');
|
|
assert.equal(typeof info.firstTimestamp, 'number');
|
|
assert.equal(typeof info.lastTimestamp, 'number');
|
|
assert.equal(typeof info.retentionTime, 'number');
|
|
assert.equal(typeof info.chunkCount, 'number');
|
|
assert.equal(typeof info.chunkSize, 'number');
|
|
assert.equal(typeof info.chunkType, 'string');
|
|
assert.equal(typeof info.duplicatePolicy, 'string');
|
|
assert.ok(Array.isArray(info.labels));
|
|
for (const label of info.labels) {
|
|
assert.equal(typeof label, 'object');
|
|
assert.equal(typeof label.name, 'string');
|
|
assert.equal(typeof label.value, 'string');
|
|
}
|
|
assert.ok(Array.isArray(info.rules));
|
|
for (const rule of info.rules) {
|
|
assert.equal(typeof rule, 'object');
|
|
assert.equal(typeof rule.aggregationType, 'string');
|
|
assert.equal(typeof rule.key, 'string');
|
|
assert.equal(typeof rule.timeBucket, 'number');
|
|
}
|
|
assert.ok(info.sourceKey === null || typeof info.sourceKey === 'string');
|
|
}
|