golden

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package golden compares produced bytes against frozen fixtures.

DevProof's format bytes are a compatibility surface (DP-015): canonical tree records, config JSON, tar headers, gzip output, and OCI manifest JSON must not change for a released format version, whatever a refactor or a dependency upgrade does. This package is the mechanism that makes such a change fail a test instead of silently reissuing every subject digest under a new identity.

Fixtures live under vectors/format/<version>/ at the repository root rather than under a testdata directory, because they are published: an implementation in another language compares its output against them, and a testdata path is a Go convention that says "ignore this". Regenerating them is correct only when introducing a new format version, never when an existing one "looks wrong". See vectors/README.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t TB, path string, got []byte)

Assert compares got against the fixture at path, failing the test on any difference.

path is interpreted relative to the calling package's directory, so a test in internal/canonical passes "../../vectors/format/v1/tree-records.bin".

func AssertString

func AssertString(t TB, path, got string)

AssertString is Assert for text fixtures, reporting a line-oriented difference rather than a hex dump.

Types

type TB

type TB interface {
	Helper()
	Logf(format string, args ...any)
	Fatalf(format string, args ...any)
}

TB is the slice of *testing.T this package needs.

It is a local interface rather than testing.TB because testing.TB cannot be implemented outside the testing package, which would leave this package's own failure reporting untestable — and a golden-byte checker that reports "match" when it should report "mismatch" is worse than no checker.

Jump to

Keyboard shortcuts

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