Calque.Snapshot (calque v1.3.1)

View Source

Represents a snapshot — a saved version of output data used by Calque’s snapshot testing system.

A snapshot encapsulates:

  • :title — A human-readable identifier, often matching the test name.
  • :content — The stringified output captured during the test run.
  • :status — Either :new (freshly generated and unreviewed) or :accepted (already validated and stored).

This module provides simple constructors to ensure consistent initialization:

  • new/2 — Creates a new, unaccepted snapshot.
  • accepted/2 — Builds an accepted snapshot loaded from disk.

Snapshots are immutable data structures; their lifecycle and comparison logic are handled by higher-level modules such as Calque and Calque.Diff.

Summary

Types

t()

@type t() :: %Calque.Snapshot{
  content: String.t(),
  status: :new | :accepted,
  title: String.t()
}

Functions

accepted(title, content)

@spec accepted(String.t(), String.t()) :: t()

new(title, content)

@spec new(String.t(), String.t()) :: t()