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

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. // TestChunkReader_ConcurrentReads checks that the chunk result can be read concurrently.
// Regression test for https://github.com/prometheus/prometheus/pull/6514. // Regression test for https://github.com/prometheus/prometheus/pull/6514.
func TestChunkReader_ConcurrentReads(t *testing.T) { func TestChunkReader_ConcurrentReads(t *testing.T) {