Debian Codegraph @

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

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