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

formattest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package formattest is the contract suite for package formats (decision 0032). Every format runs Run with a fixture that builds packages of its type, and one set of scenarios proves, on the in-memory, SQLite and PostgreSQL stores, that its package index (decision 0018) stays right on every write path the item service offers: deploy, overwrite, delete, copy, move, restore from the trash can, property changes and a remote repository's cache.

"Right" has two halves. The fixture says which versions a scenario leaves and which files each links. And the item tree is the source of truth, so the index the hooks kept must be the one the format's reindex reads from the tree: a reindex over it changes nothing, and a reindex from an empty index rebuilds it. A format that indexes nothing must leave the index empty.

The suite drives the item service, whose entry points every API calls: the properties API and AQL properties.update call Service.Annotate, which internal/server's TestPropertyWritesReachTheFormat holds them to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, f Format)

Run runs every scenario of the contract for f on every backend, each on a fresh store.

Types

type Backend

type Backend struct {
	Name string
	Open func(t *testing.T) store.Store
}

Backend opens a fresh, empty store for one scenario.

func Backends

func Backends() []Backend

Backends are the stores the suite runs on: the in-memory reference, SQLite on disk and PostgreSQL, which skips where Docker cannot run Linux containers.

type File

type File struct {
	// Path is repository-relative.
	Path string
	Body []byte
}

File is one file of a version as a client deploys it.

type Format

type Format struct {
	// Type is the package type of the repositories the suite creates.
	Type repo.PackageType
	// Layout, when set, is the repositories' repoLayoutRef.
	Layout string
	// Handler is the format; nil means the one formats.For picks for Type.
	Handler format.Handler
	// Version returns version v of package p as deployed for the nth time.
	// The suite names packages "alpha" and "beta" and versions "1.0" and
	// "2.0"; the fixture maps them to its ecosystem's names. Every n gives
	// the same paths, and n > 0 changes the content of at least one file,
	// so a redeploy overwrites.
	Version func(p, v string, n int) Version
	// Properties are the property sets the suite applies in turn to a
	// version's files: a format whose index follows properties names the
	// ones it reads. Nil means a set the format does not read.
	Properties []types.Properties
	// Work lists the kinds of work the format queues on a deploy. Each
	// committed deploy leaves exactly one item of each per package; a kind
	// not listed must never be queued.
	Work []string
	// NoRemoteCache marks a format that does not index a remote
	// repository's cache yet, as decision 0018 has the npm, Go and Maven
	// formats do. Docker sets it until its remote repositories come in P9.
	NoRemoteCache bool
}

Format is a format under the contract.

type Version

type Version struct {
	// Package and Version are what the index calls it; both are empty for
	// a format that keeps no index.
	Package, Version string
	// Files are deployed in order.
	Files []File
	// Linked are the paths of the files the index links to the version;
	// nil means every file.
	Linked []string
}

Version is one version of a package as a client deploys it.

Jump to

Keyboard shortcuts

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