docs(tower-test): add a crate overview, runnable example, and richer item docs#878
Open
ameyypawar wants to merge 2 commits into
Open
docs(tower-test): add a crate overview, runnable example, and richer item docs#878ameyypawar wants to merge 2 commits into
ameyypawar wants to merge 2 commits into
Conversation
…docs tower-test had a one-line crate doc and only terse one-line descriptions on its public items, with no usage example for the core `Mock`/`Handle` flow (tower-rs#772). Add a crate-level overview with a runnable example, and expand the descriptions of the public `mock` API (pair/spawn, `Mock`, `Handle`, `SendResponse`, and their methods). Documentation only.
`mock::spawn` is both a function and a module, so the bare links were ambiguous and failed the `broken_intra_doc_links` doc build. Point them at the function with `spawn()`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #772.
tower-testhad a one-line crate doc, terse one-line descriptions on its public items, and no usage example — making theMock/Handleflow hard to discover (the issue reporter and a +1 both bounced off it).This is a documentation-only change:
tower-test/src/lib.rs— expands the crate doc into an overview of theMock/Handlemodel and adds a runnable example covering the core flow: create a mock, call it, receive the request through the handle, respond, and observe the response future resolve.tower-test/src/mock/mod.rs— fills out the descriptions of the publicmockAPI (pair,spawn/spawn_with/spawn_layer,Mock,Handle,SendResponse, and their methods), including behaviour that wasn't documented before (e.g. a fresh mock allowsu64::MAXrequests, soHandle::allowis for applying backpressure; cloning aMockshares a singleHandle).No code changes.
Notes
The example uses
tokio_test::block_onrather than#[tokio::main], sincetower-test'stokiodependency doesn't enable thertfeature — so it compiles and runs with the crate's existing dependencies.Verified locally:
cargo test -p tower-test --docpasses (the new example runs),cargo doc -p tower-testis clean under-D rustdoc::broken_intra_doc_links, andcargo fmt --checkis clean.