Skip to main content

Crate perfgate_fake

Crate perfgate_fake 

Source
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

§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§

CommandSpec
Command to execute.
FakeClock
A fake clock that returns configurable timestamps.
FakeHostProbe
A host probe that returns pre-configured host information.
FakeProcessRunner
A process runner that returns pre-configured results for specific commands.
HostProbeOptions
MockProcessBuilder
Builder for creating mock RunResult instances.
RunResult
Result of a single execution.

Enums§

AdapterError

Traits§

ProcessRunner