1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-03 04:01:40 +03:00
Files
node-redis/packages/time-series/lib/commands/ALTER.spec.ts
Nikolay Karadzhov 7b737821b2 fix: fix various command import issues (#2944)
* fix: fix various command import issues

there was some sort of a circular dependency
in <module>/lib/commands/index.ts for various modules

fixes #2937 fixes #2941

* remove redundant definition
2025-05-07 16:10:35 +03:00

87 lines
2.3 KiB
TypeScript

import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import ALTER from './ALTER';
import { TIME_SERIES_DUPLICATE_POLICIES } from './helpers';
import { parseArgs } from '@redis/client/lib/commands/generic-transformers';
describe('TS.ALTER', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
parseArgs(ALTER, 'key'),
['TS.ALTER', 'key']
);
});
it('with RETENTION', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
RETENTION: 1
}),
['TS.ALTER', 'key', 'RETENTION', '1']
);
});
it('with CHUNK_SIZE', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
CHUNK_SIZE: 1
}),
['TS.ALTER', 'key', 'CHUNK_SIZE', '1']
);
});
it('with DUPLICATE_POLICY', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK
}),
['TS.ALTER', 'key', 'DUPLICATE_POLICY', 'BLOCK']
);
});
it('with LABELS', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
LABELS: { label: 'value' }
}),
['TS.ALTER', 'key', 'LABELS', 'label', 'value']
);
});
it('with IGNORE with MAX_TIME_DIFF', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
IGNORE: {
maxTimeDiff: 1,
maxValDiff: 1
}
}),
['TS.ALTER', 'key', 'IGNORE', '1', '1']
)
});
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS, IGNORE', () => {
assert.deepEqual(
parseArgs(ALTER, 'key', {
RETENTION: 1,
CHUNK_SIZE: 1,
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK,
LABELS: { label: 'value' },
IGNORE: { maxTimeDiff: 1, maxValDiff: 1}
}),
['TS.ALTER', 'key', 'RETENTION', '1', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
);
});
});
testUtils.testWithClient('client.ts.alter', async client => {
const [, reply] = await Promise.all([
client.ts.create('key'),
client.ts.alter('key')
]);
assert.equal(reply, 'OK');
}, GLOBAL.SERVERS.OPEN);
});