Pipeline.Test.Helpers (pipeline v0.0.1)

View Source

Common 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_file_created(path, expected_content \\ nil)

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_logged(level, message_or_pattern)

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_mock_file_created(path, expected_content \\ nil)

Assert that a file was created in the mock file system.

Uses Pipeline.Test.Mocks.FileMock to check file existence.

assert_step_executed(orchestrator, step_name)

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_logs(fun)

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_claude_step(opts)

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_gemini_step(opts)

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_temp_config_file(config_map)

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_test_config(opts \\ [])

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_mocks()

Reset all mock state (useful to run between tests).

with_temp_dir(fun)

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)