diff --git a/tsdb/db_test.go b/tsdb/db_test.go index 64fb80e75..8617828e2 100644 --- a/tsdb/db_test.go +++ b/tsdb/db_test.go @@ -2579,6 +2579,28 @@ func TestChunkWriter_ReadAfterWrite(t *testing.T) { } } +func TestRangeForTimestamp(t *testing.T) { + type args struct { + t int64 + width int64 + } + tests := []struct { + args args + expected int64 + }{ + {args{0, 5}, 5}, + {args{1, 5}, 5}, + {args{5, 5}, 10}, + {args{6, 5}, 10}, + {args{13, 5}, 15}, + {args{95, 5}, 100}, + } + for _, tt := range tests { + got := rangeForTimestamp(tt.args.t, tt.args.width) + testutil.Equals(t, tt.expected, got) + } +} + // TestChunkReader_ConcurrentReads checks that the chunk result can be read concurrently. // Regression test for https://github.com/prometheus/prometheus/pull/6514. func TestChunkReader_ConcurrentReads(t *testing.T) {