repotest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package repotest builds spec repositories for tests. Four test packages need a throwaway repository with a handful of documents in it, and cmd/archdoc will need a fifth, so the construction lives here rather than being copied.

It imports testing, as httptest and iotest do, and lives under internal/ so it never reaches a released binary.

Index

Constants

View Source
const DefaultConfig = `{"name":"T"}`

DefaultConfig is the archdoc.json used when a test does not care about the settings.

Variables

This section is empty.

Functions

func Document

func Document(t *testing.T, r *repo.Repo, path string) *repo.Document

Document finds a document by its path, failing the test if it is absent. Returning the document rather than a bool keeps the caller's assertions about the document itself.

func Fixture

func Fixture(t *testing.T, name string) *repo.Repo

Fixture opens one of the checked-in repositories under testdata. The path is relative to the calling package's directory, which for every package under internal/ and cmd/ is two levels below the module root.

func New

func New(t *testing.T, files map[string]string) *repo.Repo

New writes files into a temporary repository and opens it. Keys are paths relative to root, slash-separated; directories are created as needed.

func NewWith

func NewWith(t *testing.T, configuration string, files map[string]string) *repo.Repo

NewWith is New with a particular archdoc.json, for the tests where the setting under test lives in the configuration.

func Section

func Section(d *repo.Document, title string) (repo.Section, bool)

Section is the first section of a document with the given title.

repo.Document deliberately has no such method any more. A rule deciding whether a section holds content must read every section with that title, and an exported "just the first one" invited exactly that mistake four times before it was removed. Tests that want one section of one document are a different case, so the convenience lives here instead.

func Write

func Write(t *testing.T, dir, path, contents string)

Write puts one file into a repository, creating its directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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