Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error checks in tests #130

Open
dbanck opened this issue Aug 26, 2022 · 0 comments
Open

Improve error checks in tests #130

dbanck opened this issue Aug 26, 2022 · 0 comments

Comments

@dbanck
Copy link
Member

dbanck commented Aug 26, 2022

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:

  1. compare string representations, i.e. given.Error() == expected.Error()
  2. use reflection
  3. avoid table tests altogether
  4. include a pointer to a function which takes an error and returns a boolean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant