Expand description
Test utilities and fake implementations for perfgate testing.
This crate provides deterministic, configurable test doubles for the perfgate adapter traits. Use these in unit tests and integration tests to avoid I/O and ensure reproducible test results.
Part of the perfgate workspace.
§Available Fakes
FakeProcessRunner- Configurable process runner for testingFakeHostProbe- Configurable host probe for testingFakeClock- Configurable clock for time-based testingMockProcessBuilder- Builder pattern for creating mock process results
§Example
use perfgate_fake::{FakeProcessRunner, MockProcessBuilder};
use perfgate_adapters::{ProcessRunner, CommandSpec, RunResult};
let runner = FakeProcessRunner::new();
// Configure a result using the builder
let result = MockProcessBuilder::new()
.exit_code(0)
.wall_ms(100)
.stdout(b"hello world".to_vec())
.build();
runner.set_result(&["echo", "hello"], result);
// Now when we run the command, we get our configured result
let spec = CommandSpec {
name: "echo test".to_string(),
argv: vec!["echo".to_string(), "hello".to_string()],
cwd: None,
env: vec![],
timeout: None,
output_cap_bytes: 1024,
};
let output = runner.run(&spec).unwrap();
assert_eq!(output.exit_code, 0);
assert_eq!(output.wall_ms, 100);Structs§
- Command
Spec - Command to execute.
- Fake
Clock - A fake clock that returns configurable timestamps.
- Fake
Host Probe - A host probe that returns pre-configured host information.
- Fake
Process Runner - A process runner that returns pre-configured results for specific commands.
- Host
Probe Options - Mock
Process Builder - Builder for creating mock
RunResultinstances. - RunResult
- Result of a single execution.