Debian Codegraph @

packages/time-series/lib/commands/INCRBY.spec.ts

raw
1 import { strict as assert } from 'assert';
2 import testUtils, { GLOBAL } from '../test-utils';
3 import { transformArguments } from './INCRBY';
4
5 describe('INCRBY', () => {
6 describe('transformArguments', () => {
7 it('without options', () => {
8 assert.deepEqual(
9 transformArguments('key', 1),
10 ['TS.INCRBY', 'key', '1']
11 );
12 });
13
14 it('with TIMESTAMP', () => {
15 assert.deepEqual(
16 transformArguments('key', 1, {
17 TIMESTAMP: '*'
18 }),
19 ['TS.INCRBY', 'key', '1', 'TIMESTAMP', '*']
20 );
21 });
22
23 it('with RETENTION', () => {
24 assert.deepEqual(
25 transformArguments('key', 1, {
26 RETENTION: 1
27 }),
28 ['TS.INCRBY', 'key', '1', 'RETENTION', '1']
29 );
30 });
31
32 it('with UNCOMPRESSED', () => {
33 assert.deepEqual(
34 transformArguments('key', 1, {
35 UNCOMPRESSED: true
36 }),
37 ['TS.INCRBY', 'key', '1', 'UNCOMPRESSED']
38 );
39 });
40
41 it('without UNCOMPRESSED', () => {
42 assert.deepEqual(
43 transformArguments('key', 1, {
44 UNCOMPRESSED: false
45 }),
46 ['TS.INCRBY', 'key', '1']
47 );
48 });
49
50 it('with CHUNK_SIZE', () => {
51 assert.deepEqual(
52 transformArguments('key', 1, {
53 CHUNK_SIZE: 1
54 }),
55 ['TS.INCRBY', 'key', '1', 'CHUNK_SIZE', '1']
56 );
57 });
58
59 it('with LABELS', () => {
60 assert.deepEqual(
61 transformArguments('key', 1, {
62 LABELS: { label: 'value' }
63 }),
64 ['TS.INCRBY', 'key', '1', 'LABELS', 'label', 'value']
65 );
66 });
67
68 it('with TIMESTAMP, RETENTION, UNCOMPRESSED, CHUNK_SIZE and LABELS', () => {
69 assert.deepEqual(
70 transformArguments('key', 1, {
71 TIMESTAMP: '*',
72 RETENTION: 1,
73 UNCOMPRESSED: true,
74 CHUNK_SIZE: 1,
75 LABELS: { label: 'value' }
76 }),
77 ['TS.INCRBY', 'key', '1', 'TIMESTAMP', '*', 'RETENTION', '1', 'UNCOMPRESSED',
78 'CHUNK_SIZE', '1', 'LABELS', 'label', 'value']
79 );
80 });
81 });
82
83 testUtils.testWithClient('client.ts.incrBy', async client => {
84 assert.equal(
85 await client.ts.incrBy('key', 1, {
86 TIMESTAMP: 0
87 }),
88 0
89 );
90 }, GLOBAL.SERVERS.OPEN);
91 });