Search documentation of Plushie

# Plushie.Test.TreeHash (Plushie v0.7.2)

Copy Markdown View Source

Structural tree hash and golden-file assertions for tests.

## Summary

### Types

t()

### Functions

assert_match(tree_hash, golden_dir)

Asserts that a tree hash matches its golden file.

from_response(msg)

Builds a tree hash from a renderer `tree_hash_response` message.

from_tree(name, tree, backend \\ nil)

Builds a tree hash from a normalized UI tree.

hash(data)

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.