go-bdd / gobdd

BDD framework
https://go-bdd.github.io/gobdd/
MIT License
115 stars 20 forks source link

ctx.GetError should not return err if there's nil #93

Closed bkielbasa closed 4 years ago

bkielbasa commented 4 years ago

Describe the bug

Here's sample code:

func itReturnsNoError(t gobdd.StepTest, ctx context.Context) context.Context {
    res, err := ctx.GetError(statsErrKey{})
    if err != nil {
        t.Error(err)
    }
    if res != nil {
        t.Errorf("expected no error but %+v received", res)
    }

    return ctx
}

When I want to check if the GetError returns an error, sometimes I want to get nil from it. But, in such case the GetError will return the err as the second returned value. It should be nil as well.