Pipeline.Test.Helpers (pipeline v0.0.1)
View SourceCommon test utilities for pipeline testing.
Summary
Functions
Assert that a file was created with optional content check.
Assert that a log message was captured.
Assert that a file was created in the mock file system.
Assert that a step was executed and has results.
Capture Logger output during test execution.
Create a simple Claude step configuration.
Create a simple Gemini step configuration.
Create a temporary YAML config file for testing.
Create a test configuration from options.
Reset all mock state (useful to run between tests).
Execute a function with a temporary directory that gets cleaned up afterwards.
Functions
Assert that a file was created with optional content check.
Examples
Pipeline.Test.Helpers.assert_file_created("/tmp/test.txt")
Pipeline.Test.Helpers.assert_file_created("/tmp/test.txt", "expected content")
Assert that a log message was captured.
Examples
Pipeline.Test.Helpers.assert_logged(:info, "Starting pipeline")
Pipeline.Test.Helpers.assert_logged(:error, ~r/Error: .+/)
Assert that a file was created in the mock file system.
Uses Pipeline.Test.Mocks.FileMock to check file existence.
Assert that a step was executed and has results.
Examples
orchestrator = %Pipeline.Orchestrator{results: %{"test_step" => %{status: "completed"}}}
Pipeline.Test.Helpers.assert_step_executed(orchestrator, "test_step")
Capture Logger output during test execution.
Examples
{result, logs} = Pipeline.Test.Helpers.capture_logs(fn ->
Logger.info("Test message")
:some_result
end)
assert result == :some_result
assert Enum.any?(logs, &String.contains?(&1, "Test message"))
Create a simple Claude step configuration.
Options
:name
- Step name (required):prompt
- Prompt content or configuration:claude_options
- Claude CLI options:output_to_file
- Output file name
Create a simple Gemini step configuration.
Options
:name
- Step name (required):prompt
- Prompt content or configuration:model
- Gemini model to use:token_budget
- Token budget configuration:output_to_file
- Output file name
Create a temporary YAML config file for testing.
Examples
config_path = Pipeline.Test.Helpers.create_temp_config_file(%{
workflow: %{
name: "test",
steps: [%{name: "step1", type: "gemini", prompt: [{type: "static", content: "test"}]}]
}
})
Create a test configuration from options.
Options
:name
- Workflow name (default: "test_workflow"):steps
- List of step configurations:workspace_dir
- Workspace directory:checkpoint_enabled
- Enable checkpoints:defaults
- Default configuration values
Examples
config = Pipeline.Test.Helpers.create_test_config(
name: "test_pipeline",
steps: [
%{name: "test_step", type: "gemini", prompt: [{type: "static", content: "test"}]}
]
)
Reset all mock state (useful to run between tests).
Execute a function with a temporary directory that gets cleaned up afterwards.
Examples
Pipeline.Test.Helpers.with_temp_dir(fn temp_dir ->
#Use temp_dir for test operations
assert File.exists?(temp_dir)
end)