test

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package test compares a generated document tree against a stored JSON snapshot, and reports the first field that differs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotReadDir = errors.New("cannot read directory")
	ErrGoModNotFound = errors.New("could not find go.mod")
)

Errors reported when a snapshot file cannot be read or parsed.

Functions

This section is empty.

Types

type Config

type Config struct {
	AbsolutePath string
	TestPath     string
}

Config is the representation of a test config.

type Node

type Node struct {
	Value   any            `json:"value,omitempty"`
	Type    string         `json:"type"`
	Details map[string]any `json:"details,omitempty"`
	Nodes   []*Node        `json:"nodes,omitempty"`
}

Node is one entry in the document tree written to a JSON snapshot: its type, its value, any extra details, and its children.

type PaperTest

type PaperTest struct {
	// contains filtered or unexported fields
}

PaperTest is the unit test instance.

func New

func New(t *testing.T) *PaperTest

New creates the PaperTest instance to unit tests.

func (*PaperTest) Assert

func (m *PaperTest) Assert(structure *node.Node[core.Structure]) *PaperTest

Assert validates if the structure is the same as defined by Equals method.

func (*PaperTest) Equals

func (m *PaperTest) Equals(file string) *PaperTest

Equals defines which file will be loaded to do the comparison.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL