Skip to content

Commit

Permalink
use concrete type helper instead of interface surfing (#9585)
Browse files Browse the repository at this point in the history
* use concrete type helper instead of interface surfing

* wrap err
  • Loading branch information
drewbailey authored Dec 9, 2020
1 parent bbf1eaa commit e76add7
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions e2e/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,21 @@ func (tc *EventsTest) TestBlockedEvalEvents(f *framework.F) {
// ensure there is a deployment promotion event
testutil.WaitForResult(func() (bool, error) {
for _, e := range evalEvents {
evalRaw, ok := e.Payload["Eval"].(map[string]interface{})
if !ok {
return false, fmt.Errorf("type assertion on eval")
eval, err := e.Evaluation()
if err != nil {
return false, fmt.Errorf("event was not an evaluation %w", err)
}

ftg, ok := evalRaw["FailedTGAllocs"].(map[string]interface{})
if !ok {
continue
}
ftg := eval.FailedTGAllocs

tg, ok := ftg["one"].(map[string]interface{})
tg, ok := ftg["one"]
if !ok {
continue
}
mem := tg["DimensionExhausted"].(map[string]interface{})["memory"]

mem := tg.DimensionExhausted["memory"]
require.NotNil(t, mem, "memory dimension was nil")
memInt := int(mem.(float64))
require.Greater(t, memInt, 0, "memory dimension was zero")
require.Greater(t, mem, 0, "memory dimension was zero")
return true, nil

}
Expand Down

0 comments on commit e76add7

Please sign in to comment.