From 8b1ad5067c4d0af6f50730dd34918e53ad19132f Mon Sep 17 00:00:00 2001 From: Karl Isenberg Date: Wed, 6 Oct 2021 08:56:30 -0700 Subject: [PATCH] Add ExpErrorEvent for better e2e test failures --- pkg/testutil/events.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/pkg/testutil/events.go b/pkg/testutil/events.go index 6b3c4fc..ed5d738 100644 --- a/pkg/testutil/events.go +++ b/pkg/testutil/events.go @@ -17,6 +17,7 @@ type ExpEvent struct { EventType event.Type InitEvent *ExpInitEvent + ErrorEvent *ExpErrorEvent ActionGroupEvent *ExpActionGroupEvent ApplyEvent *ExpApplyEvent StatusEvent *ExpStatusEvent @@ -29,6 +30,10 @@ type ExpInitEvent struct { // ActionGroups []event.ActionGroup } +type ExpErrorEvent struct { + Err error +} + type ExpActionGroupEvent struct { GroupName string Action event.ResourceAction @@ -91,6 +96,20 @@ func isMatch(ee ExpEvent, e event.Event) bool { // nolint:gocritic switch e.Type { + case event.ErrorType: + a := ee.ErrorEvent + + if a == nil { + return true + } + + b := e.ErrorEvent + + if a.Err != nil { + if !cmp.Equal(a.Err, b.Err, cmpopts.EquateErrors()) { + return false + } + } case event.ActionGroupType: agee := ee.ActionGroupEvent @@ -238,6 +257,14 @@ func EventToExpEvent(e event.Event) ExpEvent { }, } + case event.ErrorType: + return ExpEvent{ + EventType: event.ErrorType, + ErrorEvent: &ExpErrorEvent{ + Err: e.ErrorEvent.Err, + }, + } + case event.ActionGroupType: return ExpEvent{ EventType: event.ActionGroupType,