@@ -979,23 +979,21 @@ func TestConvertOpenTSDBResultsToSeriesResponse(t *testing.T) {
979979 Tags : map [string ]string {},
980980 Dps : newDps (map [string ]interface {}{}),
981981 },
982- expectedOutput : storepb .NewSeriesResponse (& storepb.Series {
983- Labels : []storepb.Label {{Name : "__name__" , Value : "metric" }},
984- Chunks : []storepb.AggrChunk {},
985- }),
986- expectedChunkTypes : []storepb.Aggr {},
982+ expectedOutput : nil ,
987983 },
988984 {
989985 input : opentsdb.QueryRespItem {
990986 Metric : "metric.with.dot.and-dash" ,
991987 Tags : map [string ]string {},
992- Dps : newDps (map [string ]interface {}{}),
988+ Dps : newDps (map [string ]interface {}{
989+ "1" : 1.0 ,
990+ }),
993991 },
994992 expectedOutput : storepb .NewSeriesResponse (& storepb.Series {
995993 Labels : []storepb.Label {{Name : "__name__" , Value : "metric:with:dot:and_dash" }},
996- Chunks : []storepb.AggrChunk {},
994+ Chunks : []storepb.AggrChunk {{ MinTime : 1 , MaxTime : 1 } },
997995 }),
998- expectedChunkTypes : []storepb.Aggr {},
996+ expectedChunkTypes : []storepb.Aggr {storepb . Aggr_RAW },
999997 },
1000998 {
1001999 input : opentsdb.QueryRespItem {
@@ -1187,13 +1185,22 @@ func TestConvertOpenTSDBResultsToSeriesResponse(t *testing.T) {
11871185 expectedChunkTypes : []storepb.Aggr {storepb .Aggr_RAW },
11881186 },
11891187 }
1190- for _ , test := range testCases {
1188+ for i , test := range testCases {
11911189 store := NewOpenTSDBStore (
11921190 log .NewJSONLogger (& testLogger {t }), nil , nil , time .Duration (0 ), 1 * time .Minute , test .storeLabels , nil , nil , false , true , "foo" )
11931191 converted , _ , err := store .convertOpenTSDBResultsToSeriesResponse (& test .input )
11941192 if err != nil {
11951193 t .Errorf ("unexpected error: %s" , err .Error ())
11961194 }
1195+ if converted == nil && test .expectedOutput == nil {
1196+ continue // Expected nothing, got nothing.
1197+ }
1198+ if test .expectedOutput == nil {
1199+ t .Errorf ("expected nil, got %v" , converted )
1200+ }
1201+ if converted == nil {
1202+ t .Errorf ("%d: expected response, got nil" , i )
1203+ }
11971204 if len (converted .GetSeries ().Labels ) == len (test .expectedOutput .GetSeries ().Labels ) {
11981205 // Labels must be alphabetically sorted
11991206 for i , label := range converted .GetSeries ().Labels {
@@ -1206,7 +1213,7 @@ func TestConvertOpenTSDBResultsToSeriesResponse(t *testing.T) {
12061213 t .Errorf ("number of tags does not match" )
12071214 }
12081215 if len (test .expectedOutput .GetSeries ().Chunks ) != len (converted .GetSeries ().Chunks ) {
1209- t .Error ( " number of chunks does not match" )
1216+ t .Errorf ( "%d: number of chunks does not match", i )
12101217 }
12111218 for ci , chunk := range test .expectedOutput .GetSeries ().Chunks {
12121219 convertedChunk := converted .GetSeries ().Chunks [ci ]
0 commit comments