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

test: improve testing for api error response #216

Merged
merged 1 commit into from
Sep 17, 2024
Merged

Conversation

EdJoPaTo
Copy link
Collaborator

Using the destructuring might mistakenly result in a wrong output. This could be misleading. For example an error code of 500 would result in the panic message while its still an API Error.

This moves the assertions to assert_eq and only destructures the Error::Api

Using the destructuring might mistakenly result in a wrong output. This could be misleading. For example an error code of 500 would result in the panic message while its still an API Error.

This moves the assertions to `assert_eq` and only destructures the `Error::Api`
})) = api.send_message(&params)
{
assert_eq!("Bad Request: chat not found".to_string(), description);
if let Err(Error::Api(error)) = dbg!(api.send_message(&params)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think dbg should be removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its neat to have: when something fails the dbg output will be on the output too which helps to understand the full return value. At first, I thought to only have it on the else case, but it might also be useful when some assert fails.

@ayrat555 ayrat555 merged commit 8668b75 into master Sep 17, 2024
56 checks passed
@ayrat555 ayrat555 deleted the test-error-cases branch September 17, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants