Skip to content

Conversation

@JanZachmann
Copy link
Contributor

Summary

Status: Work in Progress - PR #1 of 14 in the test coverage improvement plan

Add comprehensive test infrastructure to support upcoming test coverage improvements from 1% to 85-90%.

Changes

Test Infrastructure

  • common/mocks.rs: Reusable mock constructors using mockall

    • mock_device_service_client_with_fleet_id() - Success case
    • mock_device_service_client_with_error() - Error case
    • mock_sso_provider_with_claims() - Success case
    • mock_sso_provider_with_error() - Error case
    • make_token_claims() - Helper for TokenClaims
    • make_api() - Complete API instance constructor
  • common/utils.rs: Test utilities for integration tests

    • create_test_app() - Test app initialization
    • create_post_request(), create_get_request() - Request builders
    • create_authenticated_request() - Bearer token auth
    • create_basic_auth_request() - Basic auth
    • load_fixture() - Load fixture files
  • fixtures/: Test fixture files

    • tokens/ - JWT tokens (valid, expired, invalid)
    • certs/ - Test certificates and keys
    • README.md - Fixture documentation
  • tests/README.md: Comprehensive documentation

    • Usage examples for all mock helpers
    • Test patterns and best practices
    • CI/CD integration notes

Documentation

  • TEST_COVERAGE_ANALYSIS.md: Full coverage analysis
    • Current coverage: 27 tests (~1-2%)
    • Detailed gap analysis by component
    • 14-PR implementation plan across 4 phases
    • Timeline: 7-10 weeks to 85-90% coverage

Test Infrastructure Design

Uses existing mockall framework with convenience wrappers:

  • Reduces boilerplate in test files
  • Consistent mock setup across tests
  • Easy to extend for new services

Test Plan

  • All existing tests pass (27 tests)
  • Mock helpers have unit tests
  • Test utilities have unit tests
  • Documentation is comprehensive

Next Steps (After Merge)

This PR enables the following PRs which can be worked on in parallel:

Related

Part of comprehensive test coverage improvement initiative.
See TEST_COVERAGE_ANALYSIS.md for full plan.

Signed-off-by: Jan Zachmann [email protected]

- Copy latest upstream/main src/ contents to src/backend/src/
- Rename vue/ to src/ui/ (previously src/frontend/)
- Update Dockerfile to reference src/ui paths
- Update build scripts for new structure
- Maintain workspace structure for future Crux integration

Signed-off-by: Jan Zachmann <[email protected]>
Add comprehensive test infrastructure to support upcoming test coverage improvements:

- common/mocks.rs: Reusable mock constructors for DeviceServiceClient and SingleSignOnProvider
- common/utils.rs: Test utilities for creating test apps, requests, and loading fixtures
- fixtures/: Test fixture files (tokens, certificates) for consistent test data
- tests/README.md: Documentation for using the test infrastructure
- TEST_COVERAGE_ANALYSIS.md: Comprehensive analysis of current test coverage and implementation plan

This infrastructure enables the planned 14 PRs to systematically increase test coverage from 1% to 85-90% across 4 phases:
- Phase 1: Security & Stability (1% → 13%)
- Phase 2: Core Device Operations (13% → 50%)
- Phase 3: API Coverage (50% → 72%)
- Phase 4: Frontend & E2E (72% → 85-90%)

All existing tests (27) pass with new infrastructure.

Signed-off-by: Jan Zachmann <[email protected]>
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