Skip to content

refactor(api): align v1 namespace and move conversion tests #1959#1963

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1959-si-7-review-tests-align-v1-namespace
Jun 30, 2026
Merged

refactor(api): align v1 namespace and move conversion tests #1959#1963
josecelano merged 3 commits into
torrust:developfrom
josecelano:1959-si-7-review-tests-align-v1-namespace

Conversation

@josecelano

Copy link
Copy Markdown
Member

Description

Implements SI-7 (#1959) - Review tests and align v1 namespace across REST API packages.

Part A: Move misplaced tests

  • Moved conversion unit tests from axum-rest-api-server to rest-api-runtime-adapter::v1::conversion (tests belong with the production code they exercise)
  • Added torrust-clock as dev-dependency to rest-api-runtime-adapter
  • Removed empty peer.rs stub (only doc comment, no code)
  • Cleaned up resources/mod.rs module declaration

Part B: Align v1 namespace

  • Added v1/ module to rest-api-application, moved ports/ and use_cases/ under it
  • Added v1/ module to rest-api-runtime-adapter, moved adapters/, container.rs, conversion.rs under it
  • Updated all internal crate:: paths
  • Updated all cross-package imports across the workspace

Verification

  • 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:

Package v1 module
rest-api-protocol v1/
rest-api-application v1/ (new)
rest-api-runtime-adapter v1/ (new)
axum-rest-api-server v1/
rest-api-client v1/



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)
Copilot AI review requested due to automatic review settings June 29, 2026 20:43

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.

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-server into rest-api-runtime-adapter::v1::conversion, adding torrust-clock as a dev-dependency where needed.
  • Introduced a v1/ module namespace in rest-api-application and rest-api-runtime-adapter, and updated all internal/cross-crate imports accordingly.
  • Removed the empty peer.rs stub 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.

@josecelano josecelano self-assigned this Jun 30, 2026
rustfmt requires files to end with a single trailing newline.
Both new v1/mod.rs files were missing trailing newlines.
@josecelano josecelano linked an issue Jun 30, 2026 that may be closed by this pull request
7 tasks
@josecelano

Copy link
Copy Markdown
Member Author

ACK 3800b12

@josecelano josecelano merged commit e47a25b into torrust:develop Jun 30, 2026
16 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.

SI-7: Review tests and align v1 namespace across REST API packages

2 participants