-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Use Assert package in the test files #186
Comments
@rexposadas Thank you for the suggestion! Our library aims to have no dependencies for as long as possible. While the testify library has some helpful features, they are not enough to make it a dependency. Having said that — we can add the single-line error checking in tests to the library. Your contribution would be greatly appreciated, along with any code coverage improvements 🙌🏻 |
I see. No problem.
Which library are you referring to? Would it be this one? https://github.com/sashabaranov/go-fastapi |
@rexposadas I mean to this library, just as a function e.g. func checkNoError(t *testing.T, err error, message string) {
if err != nil {
t.Errorf(message)
}
} |
@sashabaranov But, to keep the code consistent would mean making other functions such as: checkHasError (..), checkErrorIs(..) You're OK with that? |
@rexposadas sounds good! It might also make sense to put those into internal/test package, but I trust your judgment here. |
Great. I'll work on the PR. |
PR for this has been merged. |
Rationale
I suggest using the assert package in the tests. See: https://github.com/stretchr/testify
It'll make the code cleaner. For example in api_test.go we have:
That can be changed to:
Implementation
I've implemented this feature for production level code and it makes the test code look a lot cleaner.
If you agree with the suggestion, I am willing to make the PR for it.
The text was updated successfully, but these errors were encountered: