use concrete type helper instead of interface surfing (#9585)

* use concrete type helper instead of interface surfing

* wrap err
This commit is contained in:
Drew Bailey
2020-12-09 09:02:37 -05:00
committed by GitHub
parent bbf1eaa833
commit e76add702d

View File

@@ -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{})
ftg := eval.FailedTGAllocs
tg, ok := ftg["one"]
if !ok {
continue
}
tg, ok := ftg["one"].(map[string]interface{})
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
}