github.com/thanos-io/thanos@v0.32.5/internal/cortex/querier/queryrange/step_align_test.go (about) 1 // Copyright (c) The Cortex Authors. 2 // Licensed under the Apache License 2.0. 3 4 package queryrange 5 6 import ( 7 "context" 8 "strconv" 9 "testing" 10 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestStepAlign(t *testing.T) { 15 for i, tc := range []struct { 16 input, expected *PrometheusRequest 17 }{ 18 { 19 input: &PrometheusRequest{ 20 Start: 0, 21 End: 100, 22 Step: 10, 23 }, 24 expected: &PrometheusRequest{ 25 Start: 0, 26 End: 100, 27 Step: 10, 28 }, 29 }, 30 31 { 32 input: &PrometheusRequest{ 33 Start: 2, 34 End: 102, 35 Step: 10, 36 }, 37 expected: &PrometheusRequest{ 38 Start: 0, 39 End: 100, 40 Step: 10, 41 }, 42 }, 43 } { 44 t.Run(strconv.Itoa(i), func(t *testing.T) { 45 var result *PrometheusRequest 46 s := stepAlign{ 47 next: HandlerFunc(func(_ context.Context, req Request) (Response, error) { 48 result = req.(*PrometheusRequest) 49 return nil, nil 50 }), 51 } 52 _, err := s.Do(context.Background(), tc.input) 53 require.NoError(t, err) 54 require.Equal(t, tc.expected, result) 55 }) 56 } 57 }