testutil

package
v0.70.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for ingitdb-cli tests.

The package contains no production code. It is intentionally placed under `internal/` so it can only be imported by other packages in this module, and its functions accept `*testing.T` so they can only be called from test code.

Index

Constants

This section is empty.

Variables

View Source
var NestedListItems = []NestedListItem{
	{List: "to-buy", ID: "milk", Title: "Milk", AddedAt: "2026-09-17T10:00:00Z"},
	{List: "to-buy", ID: "bananas", Title: "Bananas", AddedAt: "2026-09-17T10:00:01Z"},
	{List: "to-buy", ID: "coffee", Title: "Coffee", AddedAt: "2026-09-17T10:00:02Z"},
	{List: "to-watch", ID: "the-matrix", Title: "The Matrix", AddedAt: "2026-09-17T10:00:03Z"},
	{List: "to-watch", ID: "interstellar", Title: "Interstellar", AddedAt: "2026-09-17T10:00:04Z"},
}

NestedListItems are the item records WriteNestedListsDB writes, in the order they were added (ascending added_at).

Functions

func MustErrContain

func MustErrContain(t testing.TB, err error, substrs ...string)

MustErrContain asserts that err is non-nil and its message contains every substring in substrs. It reports failure via t.Fatalf. t.Helper() makes the failure point at the test that called MustErrContain rather than this line.

Example:

_, err := parseInput(badInput)
testutil.MustErrContain(t, err, "$content", "collide")

func WriteDeepNestedListsDB added in v0.66.0

func WriteDeepNestedListsDB(t testing.TB) string

WriteDeepNestedListsDB writes the WriteNestedListsDB database plus a second subcollection level and an edge-case key: `items` declares subcollection `tags` (records `dairy` and `fresh` under item `milk`), and a list whose key equals the subcollection name, `lists/items`, has one item `self`.

func WriteNestedListsDB added in v0.66.0

func WriteNestedListsDB(t testing.TB) string

WriteNestedListsDB creates, in a temporary directory, an inGitDB database shaped like the TODO demo: a root collection `lists` (records `to-buy` and `to-watch`) declaring a subcollection `items` (NestedListItems). Definitions are written as files; records are written through the local driver with parent keys, so they sit at the driver's own on-disk paths. It returns the database directory.

Types

type NestedListItem added in v0.66.0

type NestedListItem struct {
	List    string
	ID      string
	Title   string
	AddedAt string
}

NestedListItem is one item record of the nested lists fixture.

Jump to

Keyboard shortcuts

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