Class FlowSnapshotStore

Namespace
Kuestenlogik.Bowire.Flows.Expectations
Assembly
Kuestenlogik.Bowire.Flows.dll

Where a flow's snapshot baselines live, and how to read and write one (#171).

public static class FlowSnapshotStore
Inheritance
FlowSnapshotStore
Inherited Members

Remarks

Beside FlowSnapshotComparer for the same reason that one is here: the CLI runner and the workbench's approve action have to agree, or a baseline approved in the browser is not the file CI later compares against — and nobody finds out until a green run says nothing.

Baselines sit in __snapshots__/ beside the flow file and are checked in with it, so drift shows up in the diff of the change that caused it. That is the Jest convention, which a reviewer already knows how to read.

Fields

DirectoryName

The directory name baselines are collected under.

public const string DirectoryName = "__snapshots__"

Field Value

string

Methods

DirectoryFor(string, string?)

The directory holding one flow's baselines.

public static string DirectoryFor(string flowPath, string? flowId)

Parameters

flowPath string

The file the flow was read from.

flowId string

The flow's id when flowPath is a workspace envelope holding several flows; null when the file is one flow.

Returns

string

Remarks

Keyed by the file's stem for a file that is one flow. That is the export format, and where every baseline already checked in lives.

Keyed by flow id inside an envelope, because there every flow shares the stem and step ids are only unique within a flow. Two flows that both name a step n1 shared one baseline file, and the failure was silent — the second flow's response overwrote the first flow's truth, and the next run compared against it and passed.

DirectoryForWorkspace(string, string?, string)

The directory holding the baselines of a flow in a saved workspace.

public static string DirectoryForWorkspace(string workspaceId, string? storageRoot, string flowId)

Parameters

workspaceId string

The workspace the flow belongs to.

storageRoot string

The checkout, for a git-native workspace; null otherwise.

flowId string

The flow.

Returns

string

Remarks

Resolved through the same seam the stores use, so a git-native workspace's baselines land in the repository and travel with a clone — which is the whole point of checking them in.

FileFor(string, string)

The baseline file for one step.

public static string FileFor(string snapshotDirectory, string stepId)

Parameters

snapshotDirectory string
stepId string

Returns

string

ReadAsync(string, string, CancellationToken)

The baseline for one step, or null when none has been captured.

public static Task<string?> ReadAsync(string snapshotDirectory, string stepId, CancellationToken ct = default)

Parameters

snapshotDirectory string
stepId string
ct CancellationToken

Returns

Task<string>

WriteAsync(string, string, string, CancellationToken)

Make body the baseline for one step.

public static Task<string> WriteAsync(string snapshotDirectory, string stepId, string body, CancellationToken ct = default)

Parameters

snapshotDirectory string
stepId string
body string
ct CancellationToken

Returns

Task<string>

The file it was written to.