Create shared test utilities module for command handlers#84
Merged
josecelano merged 3 commits intomainfrom Oct 29, 2025
Merged
Conversation
- Created `src/presentation/commands/tests/mod.rs` with shared test utilities - Implemented `TestContext` struct with automatic temp directory management - Implemented reusable test config generators: `create_valid_config`, `create_invalid_json_config`, `create_config_with_invalid_name`, `create_config_with_missing_keys` - Added comprehensive documentation following module organization guidelines - Updated `create/tests/integration.rs` to use shared utilities - Updated `create/tests/template.rs` to use shared utilities - Updated `destroy/tests/integration.rs` to use shared utilities - Removed duplicate `create/tests/fixtures.rs` file - All tests pass successfully Co-authored-by: josecelano <[email protected]>
- Added #[must_use] attributes to all config generator functions - Added #[must_use] to TestContext methods - Added Panics documentation sections for all functions that can panic - Updated doc examples to use no_run to avoid test execution in doctests - Renamed `context` variables to `test_context` to avoid similar_names warnings - Renamed `content` to `file_content` where needed - Renamed tests submodule to `unit_tests` to avoid module_inception warning - Formatted all code with rustfmt - All linters pass successfully Co-authored-by: josecelano <[email protected]>
Copilot
AI
changed the title
[WIP] Create shared test utilities module
Create shared test utilities module for command handlers
Oct 29, 2025
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.
Test utilities were duplicated across
create/tests/fixtures.rsand inconsistently implemented indestroy/tests/. This created maintenance burden and inconsistent test patterns.Changes
New shared test utilities (
src/presentation/commands/tests/mod.rs):TestContext- Manages temporary directories with automatic cleanupcreate_valid_config()- Generates valid environment configurationscreate_invalid_json_config()- Creates malformed JSON for error testingcreate_config_with_invalid_name()- Invalid environment name for validation testingcreate_config_with_missing_keys()- Non-existent SSH keys for file validation testingTest file updates:
create/tests/integration.rs- 8 tests migrated to shared utilitiescreate/tests/template.rs- 4 tests migrated to shared utilitiesdestroy/tests/integration.rs- 5 tests migrated to shared utilitiescreate/tests/fixtures.rs(162 lines)Usage
Net reduction of ~190 lines with improved consistency across all command tests.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.