Help us shape the future of Go! Take the 2026 Go Developer Survey

fixture

package
v0.0.0-...-ecb9550 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package fixture loads explicitly selected test data. Paths are always relative to a caller-declared root; test names and caller source locations are ignored.

Index

Constants

View Source
const MaxSourceBytes int64 = 64 << 20

Variables

This section is empty.

Functions

func Clone

func Clone(rows []map[string]any) (structology.Maps, error)

Clone copies maps and slices recursively, retaining scalar types such as json.Number and time.Time. Excessively deep/cyclic containers are rejected.

Types

type Resolver

type Resolver interface {
	Load(context.Context, Source) (structology.Maps, error)
	Read(context.Context, Source) ([]byte, error)
}

Resolver is safe for concurrent reads when its caller-supplied FS/AFS service is. Load returns fresh maps on every call. Read reads raw schema or fixture bytes.

func AFS

func AFS(service afs.Service, baseURL string, options ...storage.Option) Resolver

func Directory

func Directory(root string) Resolver

func Embed

func Embed(fsys *embed.FS, root string) Resolver

Embed uses the AFS embed manager directly, retaining the filesystem on every read. It never falls back to an on-disk file with the same name.

func FS

func FS(fsys fs.FS, root string) Resolver

func Inline

func Inline() Resolver

Inline resolves in-memory sources and rejects paths without an explicit root.

type Source

type Source struct {
	// Expanded marks concrete values produced by hydration/mapping. Consumers
	// must not evaluate toolbox templates in these records a second time.
	Expanded  bool             `json:"expanded,omitempty" yaml:"expanded,omitempty"`
	Kind      string           `json:"kind,omitempty" yaml:"kind,omitempty"`
	Path      string           `json:"path,omitempty" yaml:"path,omitempty"`
	URL       string           `json:"url,omitempty" yaml:"url,omitempty"`
	Format    string           `json:"format,omitempty" yaml:"format,omitempty"`
	Data      []map[string]any `json:"data,omitempty" yaml:"data,omitempty"`
	Value     any              `json:"-" yaml:"-"`
	Content   []byte           `json:"content,omitempty" yaml:"content,omitempty"`
	NullToken string           `json:"nullToken,omitempty" yaml:"nullToken,omitempty"`
}

Source describes one input. Value is reserved for in-process typed slices. Use an explicit kind for an empty maps/bytes input in serialized requests.

func Bytes

func Bytes(content []byte, format string) Source

func File

func File(name string) Source

func Maps

func Maps(rows []map[string]any) Source

func Resolved

func Resolved(rows []map[string]any) Source

Resolved wraps concrete rows without evaluating their string values again.

func Typed

func Typed(rows any) Source

func URL

func URL(location string) Source

Jump to

Keyboard shortcuts

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