Skip to content

test(axum-rest-api-server): [#2637] cover the server lifecycle - #2744

Merged
josecelano merged 13 commits into
torrust:developfrom
josecelano-bot:2637-1347-add-tests-axum-rest-api-server-lifecycle
Nov 6, 2026
Merged

josecelano merged 13 commits into
torrust:developfrom
josecelano-bot:2637-1347-add-tests-axum-rest-api-server-lifecycle

Conversation

@josecelano-bot

Copy link
Copy Markdown
Contributor

Related to #2637

Slice S5 of the torrust-tracker-axum-rest-api-server package tests (subissue of EPIC #1347): the server lifecycle (server.rs), plus two test-only fixes for post-merge review findings of earlier slices. Tests and documentation only; no production code changed.

Summary

Coverage (stable Rust 1.99.1, cargo-llvm-cov 0.6.16, filtered to packages/axum-rest-api-server/src/)

Scope S5 baseline (rebased develop, before this slice) After S5
Unit-only lines 2,172 / 2,261 (96.06%) 2,324 / 2,403 (96.71%)
Aggregate lines 2,196 / 2,261 (97.13%) 2,348 / 2,403 (97.71%)
Integration-only lines 682 / 927 (73.57%) 682 / 903 (75.53%)

The totals count the in-file test modules. develop changed the package between the baseline and the final rebase (the #2733 fix and the stats files), which also moved the integration-only denominator. Unit tests: 159 to 167 (five from this slice, the rest from develop); 58 integration tests unchanged.

Files

packages/axum-rest-api-server/ (src/server.rs, src/test_support.rs, src/routes.rs, src/v1/routes.rs, Cargo.toml), Cargo.lock, docs/issues/open/2637-1347-add-tests-axum-rest-api-server/, docs/issues/open/1347-overhaul-packages-testing/EPIC.md.

Validation

All on the rebased branch: the pre-commit script passed for every commit and ./contrib/dev-tools/git/hooks/pre-push.sh passed. cargo test -p torrust-tracker-axum-rest-api-server passed (167 unit and 58 integration tests), cargo +nightly fmt --all -- --check, cargo clippy -p torrust-tracker-axum-rest-api-server --all-targets, cargo machete --with-metadata, linter markdown and linter cspell passed. The history was rebased onto develop before the push (the branch was never pushed); no commit was squashed.

🤖 Generated with Claude Code

josecelano and others added 11 commits November 6, 2026 08:12
… and log the post-merge findings

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…abase a cleanup owner and bound the router tests

The shared api_container helper now moves a SQLite database into a temporary
directory that the returned value removes on drop, also when a test panics.
The v1 routes helper and the API router helper await container setup, the
request and the body inside one absolute deadline.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…tration cancels the caller's token

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
What changed in this PR

Adds/refactors unit tests to cover the REST API server lifecycle and improves test hygiene by enforcing timeouts and cleaning up temporary SQLite databases created during tests.

Changes:

  • Add/refactor server.rs lifecycle tests (bind error, registration details, health checks, and Launcher display).
  • Introduce shared test helpers: a global I/O deadline (within_deadline) and a tempdir-owned SQLite database container (TestApiContainer).
  • Update docs/coverage evidence and add tempfile as a dev-dependency for test cleanup.
File Description
packages/​axum-rest-api-server/​src/​v1/​routes.rs Wraps test helper I/O (container + request + body) in a shared deadline helper.
packages/​axum-rest-api-server/​src/​test_support.rs Adds within_deadline, TEST_DEADLINE, and TestApiContainer to avoid hangs and database file leaks.
packages/​axum-rest-api-server/​src/​server.rs Expands/refactors lifecycle tests; uses shared deadline + shared container helper.
packages/​axum-rest-api-server/​src/​routes.rs Wraps router test helper I/O in shared deadline helper.
packages/​axum-rest-api-server/​Cargo.toml Adds tempfile dev-dependency to support test database tempdirs.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​test-refactor-plans/​server-tests.md Adds the server lifecycle test plan and results/coverage notes.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​test-refactor-plans/​README.md Adds the new server lifecycle plan to the index.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​lessons.md Updates lessons learned with server lifecycle findings and follow-ups.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​coverage-evidence.md Records updated pre/post coverage measurements for the slice.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​agent-review-reports.md Adds the independent review report for slice S5.
docs/​issues/​open/​2637-1347-add-tests-axum-rest-api-server/​ISSUE.md Updates slice tracking, ledger status, and progress log entries.
docs/​issues/​open/​1347-overhaul-packages-testing/​EPIC.md Updates EPIC status and latest coverage metrics for #2637.

Review effort: Lite

@josecelano

Copy link
Copy Markdown
Member

ACK 275c895

@josecelano
josecelano merged commit c5a6dba into torrust:develop Nov 6, 2026
22 checks passed
@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: All 277 executable lines it added are tests, benchmarks or test support with no production behaviour, and 268 of them are still present.

This branch was previously deployed

1 inactive deployment
coverage — 275c895f Deployed Nov 6, 2026 by josecelano-bot via Generate Coverage Report #2939
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.

4 participants