Skip to content

Commit

Permalink
Add ExpErrorEvent for better e2e test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
karlkfi committed Oct 6, 2021
1 parent 2a6b353 commit 8b1ad50
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/testutil/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ExpEvent struct {
EventType event.Type

InitEvent *ExpInitEvent
ErrorEvent *ExpErrorEvent
ActionGroupEvent *ExpActionGroupEvent
ApplyEvent *ExpApplyEvent
StatusEvent *ExpStatusEvent
Expand All @@ -29,6 +30,10 @@ type ExpInitEvent struct {
// ActionGroups []event.ActionGroup
}

type ExpErrorEvent struct {
Err error
}

type ExpActionGroupEvent struct {
GroupName string
Action event.ResourceAction
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8b1ad50

Please sign in to comment.