Skip to content

test: add comprehensive unit tests for endpoint_builder module#347

Merged
josecelano merged 1 commit intomainfrom
add-unit-tests-for-endpoint-builder
Feb 13, 2026
Merged

test: add comprehensive unit tests for endpoint_builder module#347
josecelano merged 1 commit intomainfrom
add-unit-tests-for-endpoint-builder

Conversation

@josecelano
Copy link
Member

Description

This PR adds comprehensive unit tests for the endpoint_builder module in the application layer's common command handlers.

Changes

  • Added 16 unit tests covering all three public functions:
    • build_api_endpoint() - 5 tests
    • build_http_tracker_endpoint() - 5 tests
    • build_all_tracker_endpoints() - 6 tests

Test Coverage

The tests cover:

  • ✅ HTTP endpoint building (without TLS)
  • ✅ HTTPS endpoint building (with TLS)
  • ✅ Correct path handling (/api/health_check vs /health_check)
  • ✅ Port extraction from configuration
  • ✅ Instance IP usage and propagation
  • ✅ Multiple tracker endpoint building
  • ✅ Empty tracker list handling
  • ✅ Port configuration preservation

Testing Approach

Following the project's unit testing conventions:

  • Tests are in the same file using #[cfg(test)] mod tests { ... }
  • Using behavior-driven naming: it_should_{behavior}_when_{condition}
  • Pure unit tests with no external dependencies beyond domain types

Pre-commit Checks

All pre-commit checks pass:

  • ✅ Cargo machete (no unused dependencies)
  • ✅ Markdown linting
  • ✅ YAML linting
  • ✅ TOML linting
  • ✅ Spell checking
  • ✅ Clippy (all warnings fixed)
  • ✅ Rustfmt
  • ✅ ShellCheck
  • ✅ All tests pass (16/16 new tests + existing test suite)

@josecelano josecelano self-assigned this Feb 13, 2026
@josecelano
Copy link
Member Author

ACK d61aaf5

@josecelano josecelano force-pushed the add-unit-tests-for-endpoint-builder branch from d61aaf5 to 7621c1e Compare February 13, 2026 12:13
@josecelano
Copy link
Member Author

ACK 7621c1e

@josecelano josecelano merged commit 554d32c into main Feb 13, 2026
40 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