From 6cc5ac5e3d36b42a618a5781dda79206ccc3f35e Mon Sep 17 00:00:00 2001 From: "william.vanhevelingen" Date: Sun, 31 Mar 2024 10:40:52 -0700 Subject: [PATCH] test: fix TestEventNodeEvents Signed-off-by: william.vanhevelingen --- workflow/controller/operator_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/workflow/controller/operator_test.go b/workflow/controller/operator_test.go index ac9a350dc7b5..58072244f5f3 100644 --- a/workflow/controller/operator_test.go +++ b/workflow/controller/operator_test.go @@ -3984,7 +3984,7 @@ spec: makePodsPhase(ctx, woc, apiv1.PodSucceeded) woc = newWorkflowOperationCtx(woc.wf, controller) woc.operate(ctx) - assert.ElementsMatch(t, want, getEvents(controller, len(want))) + assert.ElementsMatch(t, want, getEventsWithoutAnnotations(controller, len(want))) }) } } @@ -4080,20 +4080,29 @@ spec: makePodsPhase(ctx, woc, apiv1.PodSucceeded) woc = newWorkflowOperationCtx(woc.wf, controller) woc.operate(ctx) - assert.ElementsMatch(t, want, getEvents(controller, len(want))) + assert.ElementsMatch(t, want, getEventsWithoutAnnotations(controller, len(want))) }) } } -func getEvents(controller *WorkflowController, num int) []string { +func getEventsWithoutAnnotations(controller *WorkflowController, num int) []string { c := controller.eventRecorderManager.(*testEventRecorderManager).eventRecorder.Events events := make([]string, num) for i := 0; i < num; i++ { - events[i] = <-c + event := <-c + events[i] = truncateAnnotationsFromEvent(event) } return events } +func truncateAnnotationsFromEvent(event string) string { + mapIndex := strings.Index(event, " map[") + if mapIndex != -1 { + return event[:mapIndex] + } + return event +} + func TestGetPodByNode(t *testing.T) { workflowText := ` metadata: