github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/testexporter/correctness/runner_test.go (about) 1 package correctness 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestMinQueryTime(t *testing.T) { 11 tests := []struct { 12 durationQuerySince time.Duration 13 timeQueryStart TimeValue 14 expected time.Time 15 }{ 16 { 17 expected: time.Now(), 18 }, 19 { 20 timeQueryStart: NewTimeValue(time.Unix(1234567890, 0)), 21 expected: time.Unix(1234567890, 0), 22 }, 23 { 24 durationQuerySince: 10 * time.Hour, 25 expected: time.Now().Add(-10 * time.Hour), 26 }, 27 } 28 29 for _, tt := range tests { 30 assert.WithinDuration(t, tt.expected, calculateMinQueryTime(tt.durationQuerySince, tt.timeQueryStart), 50*time.Millisecond) 31 } 32 }