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: fetch actions from mock handle before write #5814

Merged
merged 3 commits into from
Jul 3, 2023

Conversation

pbrenna
Copy link
Contributor

@pbrenna pbrenna commented Jun 23, 2023

Motivation

Fixes #5813
When the Mock object is created without actions (such as for use with its Handle), it can happen that actions from the handle are never fetched, causing an unexpected broken pipe error.

Solution

Before executing the write, if there are no actions in the Mock, try receiving from the handle if an action is ready.

Pietro Brenna added 2 commits June 23, 2023 22:34
This covers the case when a Mock is created without
any action, for use with an Handle.

Refs: tokio-rs#5813
When creating a tokio_test::io::Mock with no actions,
bew actions were never fetched from the mock Handle.
This change fetches an action from the Handle, if present.

Fixes: tokio-rs#5813
@Darksonn Darksonn added the A-tokio-test Area: The tokio-test crate label Jul 3, 2023
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM.

@Darksonn Darksonn enabled auto-merge (squash) July 3, 2023 07:45
@Darksonn Darksonn merged commit 918cf08 into tokio-rs:master Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-test Area: The tokio-test crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio_test::io::Mock does not read actions from handle when used as writer
2 participants