testing library

Test-only utilities for the durable_workflow package.

This library exposes InMemoryCheckpointStore, shared fixture factories, and runCheckpointStoreContractTests for verifying custom CheckpointStore implementations.

For production use, prefer a persistent implementation such as SqliteCheckpointStore from package:durable_workflow_sqlite.

import 'package:durable_workflow/testing.dart';

final store = InMemoryCheckpointStore();

Classes

InMemoryCheckpointStore
In-memory implementation of CheckpointStore for testing only.

Functions

createTestCheckpoint({int? id, required String workflowExecutionId, required int stepIndex, required String stepName, StepStatus status = StepStatus.completed, String? inputData, String? outputData, String? errorMessage, int attempt = 1, String? compensateRef}) StepCheckpoint
Creates a StepCheckpoint with sensible defaults for testing.
createTestExecution(String id, {String workflowId = 'wf-test-0', ExecutionStatus status = const Running(), int currentStep = 0, String? inputData, String? outputData, String? errorMessage, String? ttlExpiresAt, WorkflowGuarantee guarantee = WorkflowGuarantee.foregroundOnly}) WorkflowExecution
Creates a WorkflowExecution with sensible defaults for testing.
createTestSignal(String executionId, {String signalName = 'test-signal', String? payload, SignalStatus status = SignalStatus.pending}) WorkflowSignal
Creates a WorkflowSignal with sensible defaults for testing.
createTestTimer(String timerId, String executionId, {String stepName = 'timer-step', String? fireAt, TimerStatus status = TimerStatus.pending}) WorkflowTimer
Creates a WorkflowTimer with sensible defaults for testing.
futureTimestamp({Duration ahead = const Duration(hours: 1)}) String
ISO-8601 timestamp for a point in the future.
nowTimestamp() String
Current UTC ISO-8601 timestamp.
pastTimestamp({Duration ago = const Duration(hours: 1)}) String
ISO-8601 timestamp for a point in the past.
runCheckpointStoreContractTests(CheckpointStore createStore()) → void
Runs the full contract test suite against a CheckpointStore implementation.