From 145d7457feb4a9b6d6c597e173c6a03e54f4ecfc Mon Sep 17 00:00:00 2001 From: Charles Korn Date: Tue, 1 Aug 2023 13:27:46 +1000 Subject: [PATCH] Address PR feedback: use loop to create expected test result Signed-off-by: Charles Korn --- promql/engine_test.go | 78 ++++++++----------------------------------- 1 file changed, 14 insertions(+), 64 deletions(-) diff --git a/promql/engine_test.go b/promql/engine_test.go index 1b14e8a5d..54567d154 100644 --- a/promql/engine_test.go +++ b/promql/engine_test.go @@ -1993,72 +1993,22 @@ load 1m end := time.Unix(61, 0) interval := time.Second + // We expect the value to be 0 for t=0s to t=59s (inclusive), then 60 for t=60s and t=61s. + expectedPoints := []FPoint{} + + for t := 0; t <= 59; t++ { + expectedPoints = append(expectedPoints, FPoint{F: 0, T: int64(t * 1000)}) + } + + expectedPoints = append( + expectedPoints, + FPoint{F: 60, T: 60_000}, + FPoint{F: 60, T: 61_000}, + ) + expectedResult := Matrix{ Series{ - Floats: []FPoint{ - {F: 0, T: 0}, - {F: 0, T: 1_000}, - {F: 0, T: 2_000}, - {F: 0, T: 3_000}, - {F: 0, T: 4_000}, - {F: 0, T: 5_000}, - {F: 0, T: 6_000}, - {F: 0, T: 7_000}, - {F: 0, T: 8_000}, - {F: 0, T: 9_000}, - {F: 0, T: 10_000}, - {F: 0, T: 11_000}, - {F: 0, T: 12_000}, - {F: 0, T: 13_000}, - {F: 0, T: 14_000}, - {F: 0, T: 15_000}, - {F: 0, T: 16_000}, - {F: 0, T: 17_000}, - {F: 0, T: 18_000}, - {F: 0, T: 19_000}, - {F: 0, T: 20_000}, - {F: 0, T: 21_000}, - {F: 0, T: 22_000}, - {F: 0, T: 23_000}, - {F: 0, T: 24_000}, - {F: 0, T: 25_000}, - {F: 0, T: 26_000}, - {F: 0, T: 27_000}, - {F: 0, T: 28_000}, - {F: 0, T: 29_000}, - {F: 0, T: 30_000}, - {F: 0, T: 31_000}, - {F: 0, T: 32_000}, - {F: 0, T: 33_000}, - {F: 0, T: 34_000}, - {F: 0, T: 35_000}, - {F: 0, T: 36_000}, - {F: 0, T: 37_000}, - {F: 0, T: 38_000}, - {F: 0, T: 39_000}, - {F: 0, T: 40_000}, - {F: 0, T: 41_000}, - {F: 0, T: 42_000}, - {F: 0, T: 43_000}, - {F: 0, T: 44_000}, - {F: 0, T: 45_000}, - {F: 0, T: 46_000}, - {F: 0, T: 47_000}, - {F: 0, T: 48_000}, - {F: 0, T: 49_000}, - {F: 0, T: 50_000}, - {F: 0, T: 51_000}, - {F: 0, T: 52_000}, - {F: 0, T: 53_000}, - {F: 0, T: 54_000}, - {F: 0, T: 55_000}, - {F: 0, T: 56_000}, - {F: 0, T: 57_000}, - {F: 0, T: 58_000}, - {F: 0, T: 59_000}, - {F: 60, T: 60_000}, - {F: 60, T: 61_000}, - }, + Floats: expectedPoints, Metric: labels.EmptyLabels(), }, }