Skip to content

Add e2e suites, query-param wiring, coverage push, and CI for tests + benches#1

Merged
JedimEmO merged 6 commits into
masterfrom
feature/e2e-coverage-and-ci
Apr 25, 2026
Merged

Add e2e suites, query-param wiring, coverage push, and CI for tests + benches#1
JedimEmO merged 6 commits into
masterfrom
feature/e2e-coverage-and-ci

Conversation

@JedimEmO
Copy link
Copy Markdown
Owner

Summary

  • New ras-test-helpers dev-only crate (MockAuthProvider, mock_user, spawn_http, spawn_tcp) plus per-macro tests/e2e.rs + benches/ for all four service macros, exercising the generated client → axum router → handler chain end-to-end.
  • Wires query parameters into the rest_service! generated client. Required params serialize unconditionally; Option<T> is skipped when None. Adds typed-client coverage for required + optional + body + path-param combinations (the existing tests/http_integration.rs only exercised this via raw reqwest).
  • Lifts workspace test coverage 80.5% → 87.2% lines, 74.2% → 85.3% functions with targeted unit tests across the framework crates (rest-core, identity-core, oauth2/config, bidirectional types/server/client, jsonrpc-types, helpers/auth). 12 framework files moved to ≥95% line coverage; bidirectional-server manager.rs went from 17% → 92%.
  • New CI: ci.yml runs fmt + clippy + test + coverage on every PR and master push; bench.yml runs criterion benches on master pushes and on demand (PR runs are skipped — runner noise dominates the diffs).

Bench baselines (local, ubuntu)

Bench Median
jsonrpc_add_dispatch ~38 µs
rest_get_dispatch ~41 µs
file_upload_download_1mib ~3.2 ms
ws_echo_roundtrip ~10 ms

Test plan

  • CI `fmt` passes
  • CI `clippy` passes (errors only; legacy warnings not yet promoted to deny)
  • CI `test` passes
  • CI `coverage` produces an `lcov.info` artifact and prints a summary
  • On master push, `bench.yml` produces a `criterion-results` artifact
  • Coverage delta in the summary matches the description (~87% lines, ~85% functions)

🤖 Generated with Claude Code

JedimEmO and others added 6 commits April 25, 2026 08:16
Introduces a shared dev-only crate at crates/test-utils/ras-test-helpers
with MockAuthProvider, mock_user, and spawn_http/spawn_tcp helpers, then
wires per-macro tests/e2e.rs and benches/ for jsonrpc_service!,
file_service!, and jsonrpc_bidirectional_service!. Each suite drives the
generated reqwest/tokio-tungstenite client all the way through the axum
router and back, plus a criterion bench measuring per-call latency.

REST macro coverage lands in the next commit so its query-param e2e
cases can land together with the query-param client codegen.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The rest_service! macro already parsed `?` query syntax for the server
side, but the generated reqwest client emitted methods without query
arguments — callers had to drop down to raw reqwest to actually exercise
those endpoints. This commit teaches the client codegen to:

- include each query parameter in the function signature, in the same
  order as the macro syntax (path → query → body),
- detect Option<T> at the type level and serialize Some(_) only,
- url-encode required parameters via reqwest's `.query()` helper.

Adds the REST e2e suite + dispatch bench in the same commit so the new
typed-client query-param test cases (required + optional + body + path
combinations) land alongside the wiring they cover.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lifts workspace test coverage from 80% to 87% by adding focused unit
tests for the framework's runtime types and trait defaults. The bias
is toward "every public function called from at least one test"
rather than chasing line coverage on data-shape modules.

Files moved into the 95-100% range:
- ras-rest-core (RestError/RestResponse constructors, IntoRestError)
- ras-identity-core (NoopPermissions/StaticPermissions, error variants)
- ras-identity-oauth2/config (provider config builder + serde)
- ras-jsonrpc-bidirectional-types: error.rs, sender.rs (incl. real-sink
  WebSocketMessageSender close idempotency), manager.rs default + ext
  trait helpers via a small in-memory stub
- ras-jsonrpc-bidirectional-server: error.rs status codes, connection.rs
  context + ChannelMessageSender, handler.rs default trait methods,
  router.rs notification + error wrapping paths, plus a new
  tests/manager_unit.rs that pins down the DefaultConnectionManager
  contract (subscriptions, broadcast counts, permission filtering,
  pending-request lifecycle) without spinning up a real WebSocket
- ras-jsonrpc-bidirectional-client: error.rs constructors + From impls +
  recovery classification, config.rs full builder + URL/header paths,
  client.rs not-connected guards on call/notify/subscribe and full
  ClientBuilder setter coverage
- ras-jsonrpc-types (canonical error code constructors + serde)

Remaining gaps live in genuinely network-bound paths
(WebSocket run loop / reconnect loop) and in the openrpc-types data
crate, which is spec-shaped and lower runtime risk.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The demo's `upload` handler used `while let Some(field) = ...` and then
unconditionally returned on the first iteration, which a recent clippy
release flags as `never_loop`. Replaced with a single
`next_field().await?.ok_or_else(...)` so the control flow matches what
the code was actually doing.

Behavior is unchanged: the handler still consumes exactly the first
multipart field and returns NotFound when none is present.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the previous test-coverage.yml (which only ran cargo test) with
two workflows:

ci.yml — runs on every PR and master push, with parallel jobs for:
  * rustfmt --check
  * cargo clippy --workspace --all-targets --all-features (errors only;
    legacy warnings are not yet promoted to deny)
  * cargo test --workspace --all-features (separate build + run steps so
    failures point to the right phase)
  * cargo llvm-cov producing lcov.info as a build artifact and a printed
    summary in the job log; Codecov upload is left commented for the
    repo owner to enable with a CODECOV_TOKEN

bench.yml — runs on master pushes and on workflow_dispatch only. PRs
intentionally skip benches: GitHub runners are noisy and PR-time bench
diffs are dominated by that noise. Uploads target/criterion/ as an
artifact for trend inspection. Each macro's bench is run individually
under a short measurement window so the total runner time stays
bounded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JedimEmO JedimEmO merged commit 51d609a into master Apr 25, 2026
4 checks passed
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.

1 participant