11import { strict as assert } from 'assert' ;
22import { TimeSeriesAggregationType , TimeSeriesDuplicatePolicies } from '.' ;
33import testUtils , { GLOBAL } from '../test-utils' ;
4- import { transformArguments } from './INFO' ;
4+ import { InfoReply , transformArguments } from './INFO' ;
55
66describe ( 'INFO' , ( ) => {
77 it ( 'transformArguments' , ( ) => {
@@ -14,37 +14,40 @@ describe('INFO', () => {
1414 testUtils . testWithClient ( 'client.ts.info' , async client => {
1515 await Promise . all ( [
1616 client . ts . create ( 'key' , {
17- LABELS : { id : "2" } ,
17+ LABELS : { id : '1' } ,
1818 DUPLICATE_POLICY : TimeSeriesDuplicatePolicies . LAST
1919 } ) ,
2020 client . ts . create ( 'key2' ) ,
2121 client . ts . createRule ( 'key' , 'key2' , TimeSeriesAggregationType . COUNT , 5 ) ,
2222 client . ts . add ( 'key' , 1 , 10 )
2323 ] ) ;
2424
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' ) ) ;
4926 } , GLOBAL . SERVERS . OPEN ) ;
5027} ) ;
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