You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +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:
@@ -1,82 +1,85 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { TimeSeriesDuplicatePolicies } from '.';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './ALTER';
|
||||
import ALTER from './ALTER';
|
||||
import { TIME_SERIES_DUPLICATE_POLICIES } from '.';
|
||||
|
||||
describe('ALTER', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('without options', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key'),
|
||||
['TS.ALTER', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
it('with RETENTION', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
RETENTION: 1
|
||||
}),
|
||||
['TS.ALTER', 'key', 'RETENTION', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with CHUNK_SIZE', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
CHUNK_SIZE: 1
|
||||
}),
|
||||
['TS.ALTER', 'key', 'CHUNK_SIZE', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with DUPLICATE_POLICY', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
DUPLICATE_POLICY: TimeSeriesDuplicatePolicies.BLOCK
|
||||
}),
|
||||
['TS.ALTER', 'key', 'DUPLICATE_POLICY', 'BLOCK']
|
||||
);
|
||||
});
|
||||
|
||||
it('with LABELS', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
LABELS: { label: 'value' }
|
||||
}),
|
||||
['TS.ALTER', 'key', 'LABELS', 'label', 'value']
|
||||
);
|
||||
});
|
||||
|
||||
it('with IGNORE with MAX_TIME_DIFF', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
IGNORE: { MAX_TIME_DIFF: 1, MAX_VAL_DIFF: 1}
|
||||
}),
|
||||
['TS.ALTER', 'key', 'IGNORE', '1', '1']
|
||||
)
|
||||
});
|
||||
|
||||
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS, IGNORE', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', {
|
||||
RETENTION: 1,
|
||||
CHUNK_SIZE: 1,
|
||||
DUPLICATE_POLICY: TimeSeriesDuplicatePolicies.BLOCK,
|
||||
LABELS: { label: 'value' },
|
||||
IGNORE: { MAX_TIME_DIFF: 1, MAX_VAL_DIFF: 1}
|
||||
}),
|
||||
['TS.ALTER', 'key', 'RETENTION', '1', 'CHUNK_SIZE', '1', 'DUPLICATE_POLICY', 'BLOCK', 'LABELS', 'label', 'value', 'IGNORE', '1', '1']
|
||||
);
|
||||
});
|
||||
describe('TS.ALTER', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('without options', () => {
|
||||
assert.deepEqual(
|
||||
ALTER.transformArguments('key'),
|
||||
['TS.ALTER', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.ts.alter', async client => {
|
||||
await client.ts.create('key');
|
||||
it('with RETENTION', () => {
|
||||
assert.deepEqual(
|
||||
ALTER.transformArguments('key', {
|
||||
RETENTION: 1
|
||||
}),
|
||||
['TS.ALTER', 'key', 'RETENTION', '1']
|
||||
);
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
await client.ts.alter('key', { RETENTION: 1 }),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
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 IGNORE with MAX_TIME_DIFF', () => {
|
||||
assert.deepEqual(
|
||||
ALTER.transformArguments('key', {
|
||||
IGNORE: {
|
||||
maxTimeDiff: 1,
|
||||
maxValDiff: 1
|
||||
}
|
||||
}),
|
||||
['TS.ALTER', 'key', 'IGNORE', '1', '1']
|
||||
)
|
||||
});
|
||||
|
||||
it('with RETENTION, CHUNK_SIZE, DUPLICATE_POLICY, LABELS, IGNORE', () => {
|
||||
assert.deepEqual(
|
||||
ALTER.transformArguments('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);
|
||||
});
|
||||
|
Reference in New Issue
Block a user