Skip to content

test: adopt rstest for parameterized tests - #24

Merged
jjhafer merged 3 commits into
silvermine:masterfrom
remdalm:feat/rstest
Oct 25, 2026
Merged

jjhafer merged 3 commits into
silvermine:masterfrom
remdalm:feat/rstest

Conversation

@remdalm

@remdalm remdalm commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@remdalm
remdalm requested a review from a team October 24, 2026 09:52
@remdalm
remdalm marked this pull request as draft October 24, 2026 09:52
@remdalm
remdalm marked this pull request as ready for review October 24, 2026 10:04
Comment thread src/client.rs Resolved
Comment thread src/client.rs Resolved
Comment thread src/client.rs Resolved
Comment thread src/client.rs Resolved
- Stream a chunked body so the mid-stream body limit check runs
- Pin the early Content-Length rejection by its advertised size, replacing a
  test that passed even without the early check
- Assert lower bounds in the backoff tests, and that jitter varies
- Check that InFlightRequests::default() and new() start empty
- Use a forbidden header to show merge_headers passes defaults through, and
  assert ForbiddenHeader in the per-request rejection test
- Revoke a runtime domain mid-retry to test allowlist revalidation
- Make the security-error retry test fail during an attempt; its old error
  was raised before the retry loop, so it could never have been retried
- Cover Error::Request codes and the retryable timeout and connect branch
- Check the full message in every error serialization test
- Pass a real String in test_body_from_string
reqwest's Attempt::previous() includes the original request URL, so the
`previous().len() >= max_redirects` check stopped one redirect early:
max_redirects(1) followed none and the default of 10 followed 9. Use `>`,
as reqwest's own Policy::limited does, and add a test for a chain that is
exactly max_redirects long.

The hop-limit tests now assert the exact status and, where the status cannot
tell where the chain stopped, the final URL. Accepting any 3xx let them pass
with the bug.
Tests that ran the same check on several inputs, in one function or in sibling
functions, are now #[rstest] tables with one named case per input. Each input
passes or fails on its own and can be run by name. Scenarios, multi-aspect
checks and stateful sequences stay plain #[test] functions.

Every input is still checked. The few that were checked twice (the 408 status,
POST and PATCH, the first backoff attempt) now appear once, with their
rationale kept as a comment on the case. The tables hold 246 cases in 45
functions.

Two changes go beyond moving tests into tables:
- test_validate_header_name_blocks asserts ForbiddenHeader with the lowercased
  name instead of just is_err(). This covers test_validate_header_name_blocks_host,
  which becomes the host_lower case, and
  test_validate_header_name_error_contains_lowercased_name, which is removed.
- The three pack_ipc_response body tests become one table that compares the
  bytes after the metadata with the input body. Their different status codes
  and headers did not matter to what they tested.

rstest 0.28.0 is a dev-dependency with default features off, as
tauri-plugin-connectivity does.
@jjhafer
jjhafer merged commit 2713b9b into silvermine:master Oct 25, 2026
1 check passed
@remdalm
remdalm deleted the feat/rstest branch October 25, 2026 21:22
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.

3 participants