Skip to content

docs(tower-test): add a crate overview, runnable example, and richer item docs#878

Open
ameyypawar wants to merge 2 commits into
tower-rs:masterfrom
ameyypawar:docs/tower-test-examples
Open

docs(tower-test): add a crate overview, runnable example, and richer item docs#878
ameyypawar wants to merge 2 commits into
tower-rs:masterfrom
ameyypawar:docs/tower-test-examples

Conversation

@ameyypawar

Copy link
Copy Markdown
Contributor

Summary

Fixes #772.

tower-test had a one-line crate doc, terse one-line descriptions on its public items, and no usage example — making the Mock/Handle flow 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 the Mock/Handle model 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 public mock API (pair, spawn/spawn_with/spawn_layer, Mock, Handle, SendResponse, and their methods), including behaviour that wasn't documented before (e.g. a fresh mock allows u64::MAX requests, so Handle::allow is for applying backpressure; cloning a Mock shares a single Handle).

No code changes.

Notes

The example uses tokio_test::block_on rather than #[tokio::main], since tower-test's tokio dependency doesn't enable the rt feature — so it compiles and runs with the crate's existing dependencies.

Verified locally: cargo test -p tower-test --doc passes (the new example runs), cargo doc -p tower-test is clean under -D rustdoc::broken_intra_doc_links, and cargo fmt --check is clean.

…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()`.
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.

Improve documentation for tower-test

1 participant