Conversation
- Updated `sqlx` version in `db_integration.md` to `0.8` (fixing feature flags). - Verified `rustapi-rs` versions in docs are `0.1.300`. - Expanded `rustapi_testing.md` to include detailed documentation for `MockServer`, `TestClient`, and Expectations. - Updated Learning Path (`docs/cookbook/src/learning/README.md`) to include "Reliable Testing" and "Service Mocking". Co-authored-by: Tuntii <121901995+Tuntii@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
Updates cookbook documentation to reflect current dependency versions and expands the testing guidance around rustapi-testing’s TestClient and MockServer.
Changes:
- Update the SQLx dependency snippet to
0.8with current feature flags. - Extend the learning path docs to include a service mocking/testing step and link to
rustapi-testing. - Greatly expand
rustapi-testingdocumentation with new examples and best practices.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| docs/cookbook/src/recipes/db_integration.md | Updates SQLx version/features to match the current ecosystem and workspace usage. |
| docs/cookbook/src/learning/README.md | Adds learning-path references to service mocking/testing using rustapi-testing. |
| docs/cookbook/src/crates/rustapi_testing.md | Adds substantial new testing documentation and examples for TestClient and MockServer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| server.expect(RequestMatcher::new(Method::GET, "/external-api/data")) | ||
| .respond_with(MockResponse::new() | ||
| .status(StatusCode::OK) | ||
| .json(serde_json::json!({ "result": "success" }))) | ||
| .times(1); |
There was a problem hiding this comment.
RequestMatcher::new(Method::GET, "/external-api/data") doesn't match the actual rustapi-testing API: RequestMatcher::new() takes no args, and method/path are set via .method(...) / .path(...). Also Method isn’t brought into scope here (the rustapi_rs::prelude doesn’t re-export it), so the example as written won’t compile for readers.
| ```rust,ignore | ||
| use rustapi_testing::{MockServer, MockResponse, RequestMatcher}; | ||
|
|
||
| #[tokio::test] |
There was a problem hiding this comment.
This snippet uses TestClient, Method, and StatusCode without importing them. Consider either adding the missing use statements (e.g. use rustapi_testing::TestClient; and use http::Method;) or qualifying them (http::Method::GET, etc.) to keep the example copy/pasteable.
| The `MockServer` automatically verifies that all expectations were met when it is dropped (at the end of the test scope). If an expectation was set to be called `once` but was never called, the test will panic. | ||
|
|
||
| The client provides a fluent API for making requests and asserting responses. | ||
| - `.once()`: Must be called exactly once (default). | ||
| - `.times(n)`: Must be called exactly `n` times. | ||
| - `.at_least_once()`: Must be called 1 or more times. | ||
| - `.never()`: Must not be called. |
There was a problem hiding this comment.
The docs say expectations are automatically verified when MockServer is dropped, but MockServer’s Drop implementation only shuts the server down and does not call verify(). Unless the crate behavior is changed, the docs should instruct callers to explicitly call server.verify() at the end of the test (or assert on unmatched_requests()).
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…te-versions-and-testing-12707341404442644071 docs: update versions to 0.1.300 and expand testing documentation 6f71402
Updated documentation to align with current workspace versions (0.1.300) and sqlx 0.8. Significantly expanded testing documentation to cover MockServer and TestClient.
PR created automatically by Jules for task 12707341404442644071 started by @Tuntii