1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-09 00:22:08 +03:00
Files
node-redis/packages/time-series/lib/commands/ALTER.spec.ts
2023-09-18 15:03:07 -04:00

73 lines
1.9 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 '.';
describe('TS.ALTER', () => {
describe('transformArguments', () => {
it('without options', () => {
assert.deepEqual(
ALTER.transformArguments('key'),
['TS.ALTER', 'key']
);
});
it('with RETENTION', () => {
assert.deepEqual(
ALTER.transformArguments('key', {
RETENTION: 1
}),
['TS.ALTER', 'key', 'RETENTION', '1']
);
});
it('with CHUNK_SIZE', () => {
assert.deepEqual(
ALTER.transformArguments('key', {
CHUNK_SIZE: 1
}),
['TS.ALTER', 'key', 'CHUNK_SIZE', '1']
);
});
it('with DUPLICATE_POLICY', () => {
assert.deepEqual(
ALTER.transformArguments('key', {
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK
}),
['TS.ALTER', 'key', 'DUPLICATE_POLICY', 'BLOCK']
);
});
it('with LABELS', () => {
assert.deepEqual(
ALTER.transformArguments('key', {
LABELS: { label: 'value' }
}),
['TS.ALTER', 'key', 'LABELS', 'label', 'value']
);
});
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS', () => {
assert.deepEqual(
ALTER.transformArguments('key', {
RETENTION: 1,
CHUNK_SIZE: 1,
DUPLICATE_POLICY: TIME_SERIES_DUPLICATE_POLICIES.BLOCK,
LABELS: { label: 'value' }
}),
['TS.ALTER', 'key', 'RETENTION', '1', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value']
);
});
});
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);
});