1
1
import { strict as assert } from 'assert' ;
2
2
import { TimeSeriesAggregationType , TimeSeriesDuplicatePolicies } from '.' ;
3
3
import testUtils , { GLOBAL } from '../test-utils' ;
4
- import { transformArguments } from './INFO' ;
4
+ import { InfoReply , transformArguments } from './INFO' ;
5
5
6
6
describe ( 'INFO' , ( ) => {
7
7
it ( 'transformArguments' , ( ) => {
@@ -14,37 +14,40 @@ describe('INFO', () => {
14
14
testUtils . testWithClient ( 'client.ts.info' , async client => {
15
15
await Promise . all ( [
16
16
client . ts . create ( 'key' , {
17
- LABELS : { id : "2" } ,
17
+ LABELS : { id : '1' } ,
18
18
DUPLICATE_POLICY : TimeSeriesDuplicatePolicies . LAST
19
19
} ) ,
20
20
client . ts . create ( 'key2' ) ,
21
21
client . ts . createRule ( 'key' , 'key2' , TimeSeriesAggregationType . COUNT , 5 ) ,
22
22
client . ts . add ( 'key' , 1 , 10 )
23
23
] ) ;
24
24
25
- assert . deepEqual (
26
- await client . ts . info ( 'key' ) ,
27
- {
28
- totalSamples : 1 ,
29
- memoryUsage : 4261 ,
30
- firstTimestamp : 1 ,
31
- lastTimestamp : 1 ,
32
- retentionTime : 0 ,
33
- chunkCount : 1 ,
34
- chunkSize : 4096 ,
35
- chunkType : 'compressed' ,
36
- duplicatePolicy : 'last' ,
37
- labels : [ {
38
- name : 'id' ,
39
- value : '2'
40
- } ] ,
41
- rules : [ {
42
- aggregationType : 'COUNT' ,
43
- key : 'key2' ,
44
- timeBucket : 5
45
- } ] ,
46
- sourceKey : null
47
- }
48
- ) ;
25
+ assertInfo ( await client . ts . info ( 'key' ) ) ;
49
26
} , GLOBAL . SERVERS . OPEN ) ;
50
27
} ) ;
28
+
29
+ export function assertInfo ( info : InfoReply ) : void {
30
+ assert . equal ( typeof info . totalSamples , 'number' ) ;
31
+ assert . equal ( typeof info . memoryUsage , 'number' ) ;
32
+ assert . equal ( typeof info . firstTimestamp , 'number' ) ;
33
+ assert . equal ( typeof info . lastTimestamp , 'number' ) ;
34
+ assert . equal ( typeof info . retentionTime , 'number' ) ;
35
+ assert . equal ( typeof info . chunkCount , 'number' ) ;
36
+ assert . equal ( typeof info . chunkSize , 'number' ) ;
37
+ assert . equal ( typeof info . chunkType , 'string' ) ;
38
+ assert . equal ( typeof info . duplicatePolicy , 'string' ) ;
39
+ assert . ok ( Array . isArray ( info . labels ) ) ;
40
+ for ( const label of info . labels ) {
41
+ assert . equal ( typeof label , 'object' ) ;
42
+ assert . equal ( typeof label . name , 'string' ) ;
43
+ assert . equal ( typeof label . value , 'string' ) ;
44
+ }
45
+ assert . ok ( Array . isArray ( info . rules ) ) ;
46
+ for ( const rule of info . rules ) {
47
+ assert . equal ( typeof rule , 'object' ) ;
48
+ assert . equal ( typeof rule . aggregationType , 'string' ) ;
49
+ assert . equal ( typeof rule . key , 'string' ) ;
50
+ assert . equal ( typeof rule . timeBucket , 'number' ) ;
51
+ }
52
+ assert . ok ( info . sourceKey === null || typeof info . sourceKey === 'string' ) ;
53
+ }
0 commit comments