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

More S3 client test #255

Merged
merged 35 commits into from
Feb 4, 2023
Merged

More S3 client test #255

merged 35 commits into from
Feb 4, 2023

Conversation

TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Feb 1, 2023

  • add tests for s3_client.c

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Feb 1, 2023

Codecov Report

Merging #255 (cb69e51) into main (2433461) will increase coverage by 0.60%.
The diff coverage is 76.47%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #255      +/-   ##
==========================================
+ Coverage   86.41%   87.02%   +0.60%     
==========================================
  Files          16       16              
  Lines        4055     4037      -18     
==========================================
+ Hits         3504     3513       +9     
+ Misses        551      524      -27     
Impacted Files Coverage Δ
source/s3_client.c 86.66% <ø> (+2.56%) ⬆️
source/s3_request_messages.c 60.78% <76.47%> (+1.20%) ⬆️
source/s3_meta_request.c 92.78% <0.00%> (-0.71%) ⬇️
source/s3_endpoint.c 89.70% <0.00%> (+1.47%) ⬆️

Comment on lines 671 to 673
int error = aws_http_headers_get(message_headers, g_host_header_name, &host_value);
AWS_ASSERT(!error);
(void)error;
Copy link
Contributor

@waahm7 waahm7 Feb 3, 2023

Choose a reason for hiding this comment

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

Suggested change
int error = aws_http_headers_get(message_headers, g_host_header_name, &host_value);
AWS_ASSERT(!error);
(void)error;
AWS_ASSERT(!aws_http_headers_get(message_headers, g_host_header_name, &host_value));

Copy link
Contributor Author

@TingDaoK TingDaoK Feb 3, 2023

Choose a reason for hiding this comment

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

AWS_ASSERT will be optimized out for release build. So, you cannot use AWS_ASSERT on code that really needs to run

Copy link
Contributor

@waahm7 waahm7 Feb 3, 2023

Choose a reason for hiding this comment

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

What about precondition if we are asserting that this will never fail? Or just not checking the error at all.
Edit: Nevermind, precondition is also just an AWS_ASSERT.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If anything went wrong, we can catch the error during our tests and CI, which basically are debug build. But, anything went wrong from there, will be a programming bug, instead of something can really happen.

But, yeah, in theory, that should never fail. Just doing this to respect the return code.

Copy link
Contributor

@waahm7 waahm7 Feb 3, 2023

Choose a reason for hiding this comment

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

A fatal assert might be better. We do the same in Swift. If something slips through our tests, this will be a hard to debug bug because of ignoring the error in production which will cause failure somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic here is host header has already been set by the code above.

It should never ever error out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't really matter. I just prefer this code style to just AWS_ASSERT on this kind of things. So, it won't affect the production and we did check the possible error code for most of the case

@TingDaoK TingDaoK enabled auto-merge (squash) February 3, 2023 22:46
@TingDaoK TingDaoK merged commit c95ad5c into main Feb 4, 2023
@TingDaoK TingDaoK deleted the s3-client-test branch February 4, 2023 00:00
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.

3 participants