@@ -44,5 +44,34 @@ describe('Aggregator', function() {
4444 f . should . have . length ( 1 ) ;
4545 f [ 0 ] . should . have . deep . property ( 'points[0][1]' , 5 ) ;
4646 } ) ;
47+
48+ it ( 'should aggregate by key + tag' , function ( ) {
49+ var agg = new aggregators . Aggregator ( ) ;
50+ agg . addPoint ( metrics . Counter , 'test.mykey' , 2 , [ 'mytag1' ] , 'myhost' ) ;
51+ agg . addPoint ( metrics . Counter , 'test.mykey' , 3 , [ 'mytag2' ] , 'myhost' ) ;
52+ var f = agg . flush ( ) ;
53+ f . should . have . length ( 2 ) ;
54+ f [ 0 ] . should . have . deep . property ( 'points[0][1]' , 2 ) ;
55+ f [ 1 ] . should . have . deep . property ( 'points[0][1]' , 3 ) ;
56+ } ) ;
57+
58+ it ( 'should treat all empty tags definitions the same' , function ( ) {
59+ var agg = new aggregators . Aggregator ( ) ;
60+ agg . addPoint ( metrics . Gauge , 'noTagsKey' , 1 , null , 'myhost' ) ;
61+ agg . addPoint ( metrics . Gauge , 'noTagsKey' , 2 , undefined , 'myhost' ) ;
62+ agg . addPoint ( metrics . Gauge , 'noTagsKey' , 3 , [ ] , 'myhost' ) ;
63+ var f = agg . flush ( ) ;
64+ f . should . have . length ( 1 ) ;
65+ f [ 0 ] . should . have . deep . property ( 'points[0][1]' , 3 ) ;
66+ } ) ;
67+
68+ it ( 'should normalize the tag order' , function ( ) {
69+ var agg = new aggregators . Aggregator ( ) ;
70+ agg . addPoint ( metrics . Gauge , 'mykey' , 1 , [ 't1' , 't2' , 't3' ] , 'myhost' ) ;
71+ agg . addPoint ( metrics . Gauge , 'mykey' , 2 , [ 't3' , 't2' , 't1' ] , 'myhost' ) ;
72+ var f = agg . flush ( ) ;
73+ f . should . have . length ( 1 ) ;
74+ f [ 0 ] . should . have . deep . property ( 'points[0][1]' , 2 ) ;
75+ } ) ;
4776} ) ;
4877
0 commit comments