add testcase for rangeForTimestamp. (#6454)

Signed-off-by: johncming <johncming@yahoo.com>
This commit is contained in:
johncming 2020-08-25 23:16:43 +08:00 committed by GitHub
parent e693af6c01
commit 3e7b463908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -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) {