Debian Codegraph @

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

raw
1 import { strict as assert } from 'assert';
2 import testUtils, { GLOBAL } from '../test-utils';
3 import { transformArguments } from './MREVRANGE';
4 import { TimeSeriesAggregationType, TimeSeriesReducers } from '.';
5
6 describe('MREVRANGE', () => {
7 it('transformArguments', () => {
8 assert.deepEqual(
9 transformArguments('-', '+', 'label=value', {
10 FILTER_BY_TS: [0],
11 FILTER_BY_VALUE: {
12 min: 0,
13 max: 1
14 },
15 COUNT: 1,
16 ALIGN: '-',
17 AGGREGATION: {
18 type: TimeSeriesAggregationType.AVERAGE,
19 timeBucket: 1
20 },
21 GROUPBY: {
22 label: 'label',
23 reducer: TimeSeriesReducers.SUM
24 },
25 }),
26 ['TS.MREVRANGE', '-', '+', 'FILTER_BY_TS', '0', 'FILTER_BY_VALUE', '0', '1',
27 'COUNT', '1', 'ALIGN', '-', 'AGGREGATION', 'AVG', '1', 'FILTER', 'label=value',
28 'GROUPBY', 'label', 'REDUCE', 'SUM']
29 );
30 });
31
32 testUtils.testWithClient('client.ts.mRevRange', async client => {
33 await client.ts.add('key', 0, 0, {
34 LABELS: { label: 'value'}
35 });
36
37 assert.deepEqual(
38 await client.ts.mRevRange('-', '+', 'label=value', {
39 COUNT: 1
40 }),
41 [{
42 key: 'key',
43 samples: [{
44 timestamp: 0,
45 value: 0
46 }]
47 }]
48 );
49 }, GLOBAL.SERVERS.OPEN);
50 });