Skip to content

Commit

Permalink
test: fix TestEventNodeEvents
Browse files Browse the repository at this point in the history
Signed-off-by: william.vanhevelingen <[email protected]>
  • Loading branch information
blkperl committed Mar 31, 2024
1 parent 82a9426 commit 6cc5ac5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
})
}
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6cc5ac5

Please sign in to comment.