WIP: Add reusable test infrastructure for backend #70
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.
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 casemock_device_service_client_with_error()- Error casemock_sso_provider_with_claims()- Success casemock_sso_provider_with_error()- Error casemake_token_claims()- Helper for TokenClaimsmake_api()- Complete API instance constructorcommon/utils.rs: Test utilities for integration tests
create_test_app()- Test app initializationcreate_post_request(),create_get_request()- Request builderscreate_authenticated_request()- Bearer token authcreate_basic_auth_request()- Basic authload_fixture()- Load fixture filesfixtures/: Test fixture files
tests/README.md: Comprehensive documentation
Documentation
Test Infrastructure Design
Uses existing mockall framework with convenience wrappers:
Test Plan
Next Steps (After Merge)
This PR enables the following PRs which can be worked on in parallel:
test/auth-and-keycloak- Authorization & Keycloak teststest/token-and-login- Token/login endpoint teststest/password-management- Password management testsRelated
Part of comprehensive test coverage improvement initiative.
See TEST_COVERAGE_ANALYSIS.md for full plan.
Signed-off-by: Jan Zachmann [email protected]