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

Create StreamMock for testing Streams #5915

Merged
merged 5 commits into from Aug 12, 2023
Merged

Conversation

shade
Copy link
Contributor

@shade shade commented Aug 5, 2023

Inroduce a new mock type to tests streams and eventually sinks. Only includes next() and wait() for now.

Motivation

Basically making a generic Stream mock type #4106

Next PR I'd like to add a Sink implementation. Since Sink requires an error type, I think we can do something like this.

impl Sink<T> for StreamMock<T> {
// Consume implementation
}

impl <T: Unpin, E: Error> Sink<T> for StreamMock<Result<T,E>> {
   type Error = E;
}


Main motivation is so we can support splitting the stream mock into a AsyncRead/AsyncWrite.

@shade shade force-pushed the joe/4106 branch 3 times, most recently from ef6bda2 to 5a5e861 Compare August 5, 2023 18:25
Inroduce a new mock type to tests streams and eventually
sinks. Only includes next() and wait() for now. Fixes tokio-rs#4106
@Darksonn Darksonn added the A-tokio-test Area: The tokio-test crate label Aug 9, 2023
@Noah-Kennedy Noah-Kennedy self-requested a review August 9, 2023 16:12
tokio-test/src/stream_mock.rs Outdated Show resolved Hide resolved
tokio-test/src/stream_mock.rs Show resolved Hide resolved
@Noah-Kennedy Noah-Kennedy enabled auto-merge (squash) August 12, 2023 18:55
@Noah-Kennedy Noah-Kennedy merged commit 197757d into tokio-rs:master Aug 12, 2023
72 checks passed
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.

None yet

3 participants