StatifierUI.Fixtures.Source behaviour (StatifierUI v0.9.1)

Copy Markdown View Source

Behaviour for a host-application module that supplies fixture data.

A host implements scenarios/0 and example_events/0; StatifierUI.Fixtures.from_source/1 calls both and routes the results through the same validation new/1 applies to a JSON sidecar, so the two delivery paths in ADR-0003 converge on one struct. datasets/0 and expressions/0 are optional (ADR-0006): a host with no expressions to evaluate need not implement either.

use StatifierUI.Fixtures.Source injects empty defaults for all four callbacks, so a host that only has scenarios (or only events, or only datasets, or only expressions) can implement just the one it has.

Summary

Types

A named example datamodel for evaluating expressions, as datasets/0 returns it.

A named example event payload, as example_events/0 returns it.

A named free-standing expression fixture, as expressions/0 returns it.

A named example datamodel, as scenarios/0 returns it.

Callbacks

Named example datamodels for evaluating expressions against (ADR-0006): a dataset name mapped to a situation, which may be as small as an expression needs.

Example event payloads: an event name mapped to a sample _event.data value.

Named free-standing expression fixtures (ADR-0006): an expression name mapped to a predicator "source" string and an optional "expect" map of expected results keyed by dataset name.

Named example datamodels: a scenario name mapped to a complete example datamodel for that situation.

Types

datasets()

@type datasets() :: %{optional(String.t()) => map()}

A named example datamodel for evaluating expressions, as datasets/0 returns it.

example_events()

@type example_events() :: %{optional(String.t()) => term()}

A named example event payload, as example_events/0 returns it.

expressions()

@type expressions() :: %{optional(String.t()) => map()}

A named free-standing expression fixture, as expressions/0 returns it.

scenarios()

@type scenarios() :: %{optional(String.t()) => map()}

A named example datamodel, as scenarios/0 returns it.

Callbacks

datasets()

(optional)
@callback datasets() :: datasets()

Named example datamodels for evaluating expressions against (ADR-0006): a dataset name mapped to a situation, which may be as small as an expression needs.

example_events()

@callback example_events() :: example_events()

Example event payloads: an event name mapped to a sample _event.data value.

expressions()

(optional)
@callback expressions() :: expressions()

Named free-standing expression fixtures (ADR-0006): an expression name mapped to a predicator "source" string and an optional "expect" map of expected results keyed by dataset name.

scenarios()

@callback scenarios() :: scenarios()

Named example datamodels: a scenario name mapped to a complete example datamodel for that situation.