libcnb-test: Improve the ergonomics of ContainerContext::address_for_port
#605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously
ContainerContext::address_for_port
would panic for some failure modes, but return anOption
for others.Given that:
libcnb-test
already leans heavily into the "directly panic rather than make the tests call unwrap/expect everywhere" approachOption
usage is for when there is a bug in the test (ie: the test author forgot to callContainerConfig::expose_port
)...then it makes sense to panic instead of returning
None
.This avoids the
.unwrap()
boilerplate on the callers side, and also simplifies a future PR to switch from Bollard to using the Docker CLI (this change is being split out to reduce the size of that PR).The
expect()
message doesn't conform to the recommended "expect as precondition" style since the otherexpect()
s in the function do not either. (We can always revisit this as part of the Bollard migration.)GUS-W-13841481.