diff --git a/pkg/block/index_test.go b/pkg/block/index_test.go index 02097d4c4b..08a3b47612 100644 --- a/pkg/block/index_test.go +++ b/pkg/block/index_test.go @@ -5,6 +5,7 @@ package block import ( "context" + "github.com/stretchr/testify/require" "math" "os" "path/filepath" @@ -96,3 +97,22 @@ func TestGatherIndexHealthStatsReturnsOutOfOrderChunksErr(t *testing.T) { testutil.Equals(t, 1, stats.OutOfOrderChunks) testutil.NotOk(t, stats.OutOfOrderChunksErr()) } + +func TestSketch(t *testing.T) { + s := newSketch() + // Empty. + require.Equal(t, int64(0), s.cnt) + require.Equal(t, int64(0), s.Max()) + require.Equal(t, int64(0), s.Min()) + require.Equal(t, int64(0), s.Avg()) + require.Equal(t, int64(0), s.Quantile(0.9)) + + s.Add(1) + s.Add(2) + s.Add(3) + require.Equal(t, int64(3), s.cnt) + require.Equal(t, int64(3), s.Max()) + require.Equal(t, int64(1), s.Min()) + require.Equal(t, int64(2), s.Avg()) + require.Equal(t, int64(2), s.Quantile(0.9)) +}