From eed0c3c6b014a7cf7fe1225f9a12dad470c3a917 Mon Sep 17 00:00:00 2001
From: hagen1778 <roman@victoriametrics.com>
Date: Wed, 25 Oct 2023 16:25:26 +0200
Subject: [PATCH] app/vmalert: fix tests after
 a216fe67280bafbdbb98a2ac63eabf48fc79c91a

https://github.com/VictoriaMetrics/VictoriaMetrics/commit/a216fe67280bafbdbb98a2ac63eabf48fc79c91a
Signed-off-by: hagen1778 <roman@victoriametrics.com>
---
 app/vmalert/rule/group_test.go | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/app/vmalert/rule/group_test.go b/app/vmalert/rule/group_test.go
index 65bdd061d3..e0ac0997cd 100644
--- a/app/vmalert/rule/group_test.go
+++ b/app/vmalert/rule/group_test.go
@@ -641,7 +641,7 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
 				Interval: time.Hour,
 			},
 			"2023-08-28T11:11:00+00:00",
-			"2023-08-28T10:59:30+00:00",
+			"2023-08-28T11:00:00+00:00",
 		},
 		{
 			"without query align + default evalDelay",
@@ -671,13 +671,22 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
 			"2023-08-28T11:30:00+00:00",
 		},
 		{
-			"with eval_delay",
+			"1h interval with eval_delay",
 			&Group{
 				EvalDelay: &evalDelay,
 				Interval:  time.Hour,
 			},
 			"2023-08-28T11:41:00+00:00",
-			"2023-08-28T10:59:00+00:00",
+			"2023-08-28T11:00:00+00:00",
+		},
+		{
+			"1m interval with eval_delay",
+			&Group{
+				EvalDelay: &evalDelay,
+				Interval:  time.Minute,
+			},
+			"2023-08-28T11:41:13+00:00",
+			"2023-08-28T11:40:00+00:00",
 		},
 		{
 			"disable alignment with eval_delay",
@@ -687,16 +696,18 @@ func TestGetPrometheusReqTimestamp(t *testing.T) {
 				evalAlignment: &disableAlign,
 			},
 			"2023-08-28T11:41:00+00:00",
-			"2023-08-28T11:40:00+00:00",
+			"2023-08-28T11:40:00+00:02",
 		},
 	}
 	for _, tc := range testCases {
-		originT, _ := time.Parse(time.RFC3339, tc.originTS)
-		expT, _ := time.Parse(time.RFC3339, tc.expTS)
-		gotTS := tc.g.adjustReqTimestamp(originT)
-		if !gotTS.Equal(expT) {
-			t.Fatalf("get wrong prometheus request timestamp, expect %s, got %s", expT, gotTS)
-		}
+		t.Run(tc.name, func(t *testing.T) {
+			originT, _ := time.Parse(time.RFC3339, tc.originTS)
+			expT, _ := time.Parse(time.RFC3339, tc.expTS)
+			gotTS := tc.g.adjustReqTimestamp(originT)
+			if !gotTS.Equal(expT) {
+				t.Fatalf("get wrong prometheus request timestamp, expect %s, got %s", expT, gotTS)
+			}
+		})
 	}
 }