fix(storage): Add unit tests to verify nil cursor

When matching series have no data, the NewGroupResultSet cursor should
return nil. Added tests to verify these conditions.
pull/10616/head
Stuart Carnie 2018-12-12 14:27:11 -07:00
parent f2891c3f59
commit 8c296dd20a
No known key found for this signature in database
GPG Key ID: 848D9C9718D78B4F
1 changed files with 30 additions and 0 deletions

View File

@ -193,6 +193,36 @@ group:
}
}
func TestNewGroupResultSet_GroupNone_NoDataReturnsNil(t *testing.T) {
newCursor := func() (reads.SeriesCursor, error) {
return &sliceSeriesCursor{
rows: newSeriesRows(
"aaa,tag0=val00",
"aaa,tag0=val01",
)}, nil
}
rs := reads.NewGroupResultSet(context.Background(), &datatypes.ReadRequest{Group: datatypes.GroupNone}, newCursor)
if rs != nil {
t.Errorf("expected nil cursor")
}
}
func TestNewGroupResultSet_GroupBy_NoDataReturnsNil(t *testing.T) {
newCursor := func() (reads.SeriesCursor, error) {
return &sliceSeriesCursor{
rows: newSeriesRows(
"aaa,tag0=val00",
"aaa,tag0=val01",
)}, nil
}
rs := reads.NewGroupResultSet(context.Background(), &datatypes.ReadRequest{Group: datatypes.GroupBy, GroupKeys: []string{"tag0"}}, newCursor)
if rs != nil {
t.Errorf("expected nil cursor")
}
}
func TestNewGroupResultSet_Sorting(t *testing.T) {
tests := []struct {
name string