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

fixture

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package fixture holds the DTOs of the generator's test registry: every mapping case of encoding/json the generator follows. Only the tests import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	ID   uuid.UUID `json:"id"`
	Size int64     `json:"size"`
	Type string    `json:"type"`
}

Attachment answers the upload.

type Audit

type Audit struct {
	CreatedAt time.Time  `json:"createdAt"`
	UpdatedAt *time.Time `json:"updatedAt"`
}

Audit is embedded by value and flattened.

type Cents

type Cents int64

Cents is a named number.

type Code

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

Code marshals itself as text.

func (Code) MarshalText

func (c Code) MarshalText() ([]byte, error)

MarshalText writes the code.

func (*Code) UnmarshalText

func (c *Code) UnmarshalText(text []byte) error

UnmarshalText reads the code, so the Go client decodes what the server wrote.

type Color

type Color string

Color is a named string type without listed values: an alias of string.

type CreateEmbedded

type CreateEmbedded struct {
	Primary
	Secondary
	Name string `json:"name"`
}

CreateEmbedded is a create body whose JSON id lives in an embedded struct, beside another embedded field ID: the client fills body.Primary.ID.

type CreateHidden

type CreateHidden struct {
	Name string `json:"name"`
	// contains filtered or unexported fields
}

CreateHidden promotes its JSON id from an unexported embedded struct: the client fills body.ID, which compiles from another package.

type CreateLabel

type CreateLabel struct {
	ID   Color  `json:"id"`
	Name string `json:"name"`
}

CreateLabel is a create body whose client id is a named string.

type CreateNote

type CreateNote struct {
	ID   *uuid.UUID `json:"id,omitempty"`
	Text string     `json:"text"`
}

CreateNote is a create body whose client id is a pointer.

type CreatePart

type CreatePart struct {
	ID   uuid.UUID `json:"id,omitzero"`
	Name string    `json:"name" validate:"required"`
	Kind Kind      `json:"kind"`
}

CreatePart is the body of the create mutation; its id is the client's (D18).

type CreateThroughPointer

type CreateThroughPointer struct {
	*Primary
	Name string `json:"name"`
}

CreateThroughPointer promotes its id through an embedded pointer, which may be nil: the client refuses to fill it.

type Dashboard

type Dashboard struct {
	Title string        `json:"title"`
	Pages []Page[Stat]  `json:"pages"`
	Tree  Node          `json:"tree"`
	Limit time.Duration `json:"limit"`
}

Dashboard is the item of the test object.

type DecodesItself

type DecodesItself struct {
	Hook fmt.Stringer `json:"hook"`
}

DecodesItself has UnmarshalJSON, so the field it holds is its own business: decodes.

func (*DecodesItself) UnmarshalJSON

func (*DecodesItself) UnmarshalJSON([]byte) error

UnmarshalJSON reads anything.

type Dimensions

type Dimensions struct {
	Width  float64 `json:"width"`
	Height float32 `json:"height"`
}

Dimensions is embedded under a JSON name, so it is one field.

type EmbedsDecoder

type EmbedsDecoder struct {
	DecodesItself
}

EmbedsDecoder decodes through the UnmarshalJSON it promotes.

type HoldsStringer

type HoldsStringer struct {
	Hook fmt.Stringer `json:"hook"`
}

HoldsStringer has an interface field with methods, which encoding/json cannot fill.

type HoldsTextBytes

type HoldsTextBytes struct {
	Data TextBytes `json:"data"`
}

HoldsTextBytes has a TextBytes field.

type HoldsTextKeys

type HoldsTextKeys struct {
	Counts map[TextKey]int `json:"counts"`
}

HoldsTextKeys has a map of TextKey keys.

type HoldsTextOnly

type HoldsTextOnly struct {
	Inner []TextOnly `json:"inner"`
}

HoldsTextOnly reaches TextOnly through a field.

type JSONOnly

type JSONOnly struct{}

JSONOnly marshals itself but reads nothing back: refused.

func (JSONOnly) MarshalJSON

func (JSONOnly) MarshalJSON() ([]byte, error)

MarshalJSON writes a string the struct cannot be read from.

type JSONWithText

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

JSONWithText writes a JSON string and reads it back through UnmarshalText: decodes.

func (JSONWithText) MarshalJSON

func (j JSONWithText) MarshalJSON() ([]byte, error)

MarshalJSON writes the value as a JSON string.

func (*JSONWithText) UnmarshalText

func (j *JSONWithText) UnmarshalText(text []byte) error

UnmarshalText reads the string.

type Kind

type Kind string

Kind is a named string type the test registry lists in Options.Enums.

const (
	KindBolt Kind = "bolt"
	KindNut  Kind = "nut"
)

The kinds.

type Node

type Node struct {
	Name     string `json:"name"`
	Children []Node `json:"children"`
}

Node is recursive.

type Note

type Note struct {
	ID   int    `json:"id"`
	Text string `json:"text"`
}

Note is the item of the resource that is not live.

type Owner

type Owner struct {
	OwnerID uuid.UUID `json:"ownerId"`
}

Owner is embedded by pointer and flattened.

type Page

type Page[Item any] struct {
	Items []Item `json:"items"`
	Count int    `json:"count"`
}

Page is a generic DTO: its instantiation is named after its argument.

type Part

type Part struct {
	Audit
	*Owner

	Dimensions  `json:"dimensions"`
	ID          uuid.UUID         `json:"id"`
	Name        string            `json:"name"`
	Kind        Kind              `json:"kind"`
	Color       Color             `json:"color"`
	Price       *float64          `json:"price"`
	Secret      string            `json:"secret"`
	Notes       string            `json:"notes,omitempty"`
	Previous    *Kind             `json:"previous,omitempty"`
	Tags        Tags              `json:"tags"`
	Labels      []string          `json:"labels,omitempty"`
	Sizes       []string          `json:"sizes" enum:"s,m,l"`
	Grade       string            `json:"grade" enum:"a,b"`
	Counts      map[string]int    `json:"counts"`
	Names       map[int]string    `json:"names,omitzero"`
	Children    []*Part           `json:"children"`
	Matrix      [3]int            `json:"matrix"`
	Checksum    []byte            `json:"checksum"`
	Total       Cents             `json:"total"`
	Large       int64             `json:"large,string"`
	Flag        *bool             `json:"flag,string"`
	Version     int               `json:"version"`
	Expires     time.Time         `json:"expires,omitzero"`
	Started     time.Time         `json:"started,omitempty"`
	Extra       json.RawMessage   `json:"extra"`
	Anything    any               `json:"anything"`
	Payload     Raw               `json:"payload"`
	Code        Code              `json:"code"`
	ContentType string            `json:"content-type"`
	Dash        string            `json:"-,"` //nolint:staticcheck // SA5008: the key "-", a mapping case under test
	Skipped     string            `json:"-"`
	Inline      struct{ A int }   `json:"inline"`
	Metadata    map[string]string `json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

Part is the item of the test resource.

type PointerCodec

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

PointerCodec marshals and unmarshals through pointer receivers: decodes.

func (*PointerCodec) MarshalJSON

func (p *PointerCodec) MarshalJSON() ([]byte, error)

MarshalJSON writes the value.

func (*PointerCodec) UnmarshalJSON

func (p *PointerCodec) UnmarshalJSON(data []byte) error

UnmarshalJSON reads the value.

type Primary

type Primary struct {
	ID uuid.UUID `json:"id"`
}

Primary carries the JSON id of CreateEmbedded.

type Raw

type Raw struct{}

Raw marshals itself: nothing is known about its JSON.

func (Raw) MarshalJSON

func (Raw) MarshalJSON() ([]byte, error)

MarshalJSON writes an empty object.

func (*Raw) UnmarshalJSON

func (*Raw) UnmarshalJSON([]byte) error

UnmarshalJSON reads what MarshalJSON wrote: a type that marshals itself must unmarshal itself, or the Go client refuses it (D67).

type RenamePart

type RenamePart struct {
	Name string `json:"name"`
}

RenamePart is the body of the rename mutation.

type Secondary

type Secondary struct {
	ID uuid.UUID `json:"otherId"`
}

Secondary has the Go field ID too, under another JSON name.

type Stat

type Stat struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Hits int    `json:"hits"`
}

Stat is the item of the test list; Hits is guarded.

type Tags

type Tags []string

Tags is a named slice: nullable where it is used.

type TextBytes

type TextBytes []byte

TextBytes is a byte slice with UnmarshalText only: encoding/json writes it as a base64 string and reads that string back through UnmarshalText, so it decodes.

func (*TextBytes) UnmarshalText

func (b *TextBytes) UnmarshalText(text []byte) error

UnmarshalText keeps the text it is given, the base64 encoding/json wrote.

type TextKey

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

TextKey is a map key that marshals itself as text only: refused as a key.

func (TextKey) MarshalText

func (k TextKey) MarshalText() ([]byte, error)

MarshalText writes the key.

type TextOnly

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

TextOnly marshals itself as text but cannot read it back: the Go client refuses it.

func (TextOnly) MarshalText

func (t TextOnly) MarshalText() ([]byte, error)

MarshalText writes the value.

type TextReader

type TextReader struct {
	Name string `json:"name"`
}

TextReader is a struct with UnmarshalText only: written as an object, which UnmarshalText cannot read; refused.

func (*TextReader) UnmarshalText

func (t *TextReader) UnmarshalText(text []byte) error

UnmarshalText reads a name.

type TextString

type TextString string

TextString is a string kind with MarshalText: encoding/json reads the text as the string.

func (TextString) MarshalText

func (t TextString) MarshalText() ([]byte, error)

MarshalText writes the string upper-cased.

Directories

Path Synopsis
Package billing holds DTOs whose Go names repeat the fixture package's: the generator qualifies both with their package's name.
Package billing holds DTOs whose Go names repeat the fixture package's: the generator qualifies both with their package's name.
Package fixtureclient is the Go client of the API at /api/v1 (D19, D67), generated from its livewire registry: build a Client with New and call one method per read, mutation, upload and export.
Package fixtureclient is the Go client of the API at /api/v1 (D19, D67), generated from its livewire registry: build a Client with New and call one method per read, mutation, upload and export.
Package fixturecommand is the command-line client fixture of the API at /api/v1 (D19, D20), on github.com/urfave/cli/v3, generated from its livewire registry: one command per declaration and read kind, the parameters as flags, a body as --body or on stdin, the answers as JSON on stdout and the diagnostics on stderr.
Package fixturecommand is the command-line client fixture of the API at /api/v1 (D19, D20), on github.com/urfave/cli/v3, generated from its livewire registry: one command per declaration and read kind, the parameters as flags, a body as --body or on stdin, the answers as JSON on stdout and the diagnostics on stderr.

Jump to

Keyboard shortcuts

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