Plushie.Test.TreeHash (Plushie v0.6.0)

Copy Markdown View Source

Structural tree hash and golden-file assertions for tests.

Summary

Functions

Asserts that a tree hash matches its golden file.

Builds a tree hash from a renderer tree_hash_response message.

Builds a tree hash from a normalized UI tree.

Computes a SHA-256 hash of the given binary data.

Types

t()

@type t() :: %Plushie.Test.TreeHash{
  backend: Plushie.Automation.backend_mode() | nil,
  hash: String.t(),
  name: String.t()
}

Functions

assert_match(tree_hash, golden_dir)

@spec assert_match(tree_hash :: t(), golden_dir :: String.t()) :: :ok

Asserts that a tree hash matches its golden file.

from_response(msg)

@spec from_response(map()) :: t()

Builds a tree hash from a renderer tree_hash_response message.

from_tree(name, tree, backend \\ nil)

@spec from_tree(
  name :: String.t(),
  tree :: map(),
  backend :: Plushie.Automation.backend_mode() | nil
) :: t()

Builds a tree hash from a normalized UI tree.

hash(data)

@spec hash(data :: binary()) :: String.t()

Computes a SHA-256 hash of the given binary data.