refactor(api): align v1 namespace and move conversion tests #1959#1963
Merged
josecelano merged 3 commits intoJun 30, 2026
Merged
Conversation
Part A: Move misplaced tests - Move conversion unit tests from axum-rest-api-server to rest-api-runtime-adapter::v1::conversion (tests belong with the production code they exercise) - Add torrust-clock dev-dependency to rest-api-runtime-adapter - Remove empty peer.rs stub (only doc comment, no code) - Clean up resources/mod.rs module declaration Part B: Align v1 namespace - Add v1/ module to rest-api-application, move ports/ and use_cases/ under it - Add v1/ module to rest-api-runtime-adapter, move adapters/, container.rs, conversion.rs under it - Update all internal crate:: paths - Update all cross-package imports across workspace (axum-rest-api-server, src/bootstrap, src/container)
There was a problem hiding this comment.
Pull request overview
Refactors the REST API workspace crates to consistently expose a v1 module namespace and relocates conversion unit tests to the crate that owns the conversion logic (rest-api-runtime-adapter), aligning package boundaries with the contract-first migration work in #1959.
Changes:
- Moved domain→protocol conversion unit tests from
axum-rest-api-serverintorest-api-runtime-adapter::v1::conversion, addingtorrust-clockas a dev-dependency where needed. - Introduced a
v1/module namespace inrest-api-applicationandrest-api-runtime-adapter, and updated all internal/cross-crate imports accordingly. - Removed the empty
peer.rsstub module and cleaned up the torrent resources module declarations.
Reviewed changes
Copilot reviewed 32 out of 41 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/container.rs | Update runtime-adapter container import to v1::container. |
| src/bootstrap/jobs/tracker_apis.rs | Update runtime-adapter container import (including test module). |
| packages/rest-api-runtime-adapter/src/lib.rs | Switch public surface to pub mod v1;. |
| packages/rest-api-runtime-adapter/src/v1/mod.rs | Add new v1 module entrypoint for runtime-adapter. |
| packages/rest-api-runtime-adapter/src/v1/container.rs | Move/introduce v1-scoped runtime adapter DI container. |
| packages/rest-api-runtime-adapter/src/v1/conversion.rs | Host conversion functions under v1 and add moved unit tests. |
| packages/rest-api-runtime-adapter/src/v1/adapters/mod.rs | Add v1 adapter module tree. |
| packages/rest-api-runtime-adapter/src/v1/adapters/auth_key.rs | Update application port import to rest-api-application::v1::ports. |
| packages/rest-api-runtime-adapter/src/v1/adapters/stats.rs | Update application port import to rest-api-application::v1::ports. |
| packages/rest-api-runtime-adapter/src/v1/adapters/torrent.rs | Update application port import to rest-api-application::v1::ports. |
| packages/rest-api-runtime-adapter/src/v1/adapters/whitelist.rs | Update application port import to rest-api-application::v1::ports. |
| packages/rest-api-runtime-adapter/Cargo.toml | Add torrust-clock as dev-dependency for moved tests. |
| packages/rest-api-application/src/lib.rs | Switch public surface to pub mod v1;. |
| packages/rest-api-application/src/v1/mod.rs | Add new v1 module entrypoint for application layer. |
| packages/rest-api-application/src/v1/ports/mod.rs | Add v1 ports module tree. |
| packages/rest-api-application/src/v1/ports/auth_key.rs | Define v1 auth-key port trait under v1/ports. |
| packages/rest-api-application/src/v1/ports/stats.rs | Define v1 stats query port trait under v1/ports. |
| packages/rest-api-application/src/v1/ports/torrent.rs | Define v1 torrent query port trait under v1/ports. |
| packages/rest-api-application/src/v1/ports/whitelist.rs | Define v1 whitelist command port trait under v1/ports. |
| packages/rest-api-application/src/v1/use_cases/mod.rs | Add v1 use-cases module tree. |
| packages/rest-api-application/src/v1/use_cases/auth_key.rs | Update internal port import to crate::v1::ports. |
| packages/rest-api-application/src/v1/use_cases/stats.rs | Update internal port import to crate::v1::ports. |
| packages/rest-api-application/src/v1/use_cases/torrent.rs | Update internal port import to crate::v1::ports. |
| packages/rest-api-application/src/v1/use_cases/whitelist.rs | Update internal port import to crate::v1::ports. |
| packages/axum-rest-api-server/src/routes.rs | Update runtime-adapter container import to v1::container. |
| packages/axum-rest-api-server/src/server.rs | Update runtime-adapter container import (including test module). |
| packages/axum-rest-api-server/src/testing/environment.rs | Update runtime-adapter container import to v1::container. |
| packages/axum-rest-api-server/src/v1/routes.rs | Update application/use-case and runtime-adapter adapter imports to v1 namespaces. |
| packages/axum-rest-api-server/src/v1/context/auth_key/routes.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/auth_key/handlers.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/stats/routes.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/stats/handlers.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/torrent/routes.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/torrent/handlers.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/torrent/resources/torrent.rs | Remove misplaced conversion unit tests (now in runtime adapter). |
| packages/axum-rest-api-server/src/v1/context/torrent/resources/peer.rs | Remove empty stub module file. |
| packages/axum-rest-api-server/src/v1/context/torrent/resources/mod.rs | Remove peer module declaration. |
| packages/axum-rest-api-server/src/v1/context/whitelist/routes.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/src/v1/context/whitelist/handlers.rs | Update application use-case import to v1::use_cases. |
| packages/axum-rest-api-server/tests/server/v1/contract/context/torrent.rs | Update conversion module import to rest-api-runtime-adapter::v1::conversion. |
| Cargo.lock | Record torrust-clock added to runtime-adapter dev-dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
rustfmt requires files to end with a single trailing newline. Both new v1/mod.rs files were missing trailing newlines.
7 tasks
Member
Author
|
ACK 3800b12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements SI-7 (#1959) - Review tests and align v1 namespace across REST API packages.
Part A: Move misplaced tests
axum-rest-api-servertorest-api-runtime-adapter::v1::conversion(tests belong with the production code they exercise)torrust-clockas dev-dependency torest-api-runtime-adapterpeer.rsstub (only doc comment, no code)resources/mod.rsmodule declarationPart B: Align v1 namespace
v1/module torest-api-application, movedports/anduse_cases/under itv1/module torest-api-runtime-adapter, movedadapters/,container.rs,conversion.rsunder itcrate::pathsVerification
cargo check --workspace✅cargo test -p torrust-tracker-rest-api-runtime-adapter✅ (2 tests pass)cargo test -p torrust-tracker-axum-rest-api-server --lib✅ (1 test passes)cargo check --tests --workspace✅Now all 5 REST API packages consistently use
v1/module namespace:rest-api-protocolv1/rest-api-applicationv1/(new)rest-api-runtime-adapterv1/(new)axum-rest-api-serverv1/rest-api-clientv1/