Skip to content

Commit

Permalink
feat: expand test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jdockerty committed Jan 12, 2024
1 parent cf5717a commit e904943
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tsdb/series_cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (cur *seriesCursor) Next() (*SeriesCursorRow, error) {

cur.row.Name, cur.row.Tags = ParseSeriesKey(cur.keys[cur.ofs])
if cur.row.Name == nil && cur.row.Tags == nil {
return nil, fmt.Errorf("series key was not valid: %s", cur.keys[cur.ofs])
return nil, fmt.Errorf("series key was not valid: %+v", cur.keys[cur.ofs])
}
cur.ofs++

Expand Down
10 changes: 8 additions & 2 deletions tsdb/series_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ func TestParseSeriesKeyMeasurement(t *testing.T) {
tests := []struct {
name string
measurement []byte
expected []byte
}{
{name: "invalid measurement", measurement: []byte{}},
{name: "invalid measurement", measurement: tsdb.AppendSeriesKey(nil, []byte{}, nil), expected: nil},
{name: "valid measurement", measurement: tsdb.AppendSeriesKey(nil, []byte("cpu"), nil), expected: []byte("cpu")},
}

for _, tt := range tests {
tsdb.ParseSeriesKey(tt.measurement)
name, _ := tsdb.ParseSeriesKey(tt.measurement)
if res := bytes.Compare(name, tt.expected); res != 0 {
t.Fatalf("invalid series key parse: got %q, expected %q", name, tt.expected)
}

}

}
Expand Down

0 comments on commit e904943

Please sign in to comment.