Open
Description
Go 1.19 discovered a minor flaw in our tests in #129: second argument to errors.As should not be *error
Changing the type of expectedErr
in our test table to interface{}
silenced that error for now but defeated the purpose of testing if the function throws the correct error. So currently, any error (or even any non nil
value) will make the test pass.
Proposal
There are a couple of different solutions to solve this:
- compare string representations, i.e. given.Error() == expected.Error()
- use reflection
- avoid table tests altogether
- include a pointer to a function which takes an error and returns a boolean