Skip to main content

Module mock_executor

Module mock_executor 

Source
Expand description

Mock Command Executor for Testing Quality Gates

This module provides infrastructure for mocking external command execution to enable unit testing of quality gate logic without running actual commands.

§Design

Uses trait-based dependency injection to allow:

  • Real execution in production (RealCommandExecutor)
  • Mock execution in tests (MockCommandExecutor)

§Example

let mut mock = MockCommandExecutor::new();
mock.register("cargo", &["clippy"], CommandResult::success("Clippy passed"));
let result = mock.execute("cargo", &["clippy"]);
assert!(result.success);

Structs§

CommandKey
Key for identifying a command (program + args combination)
CommandResult
Result of command execution
MockCommandExecutor
Mock command executor for testing
RealCommandExecutor
Real command executor using std::process::Command

Traits§

CommandExecutor
Trait for executing external commands