testutil

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

func Chdir(t *testing.T, dir string)

Chdir changes the working directory to dir and registers a t.Cleanup to restore the original CWD. Use this when commands under test rely on os.Getwd() to find .lore/.

WARNING: not goroutine-safe — tests using Chdir must NOT call t.Parallel(). Process-wide CWD is shared state; parallel tests would race on it.

func SetupGitRepo

func SetupGitRepo(t *testing.T) string

SetupGitRepo creates a temporary Git repo (git init) and returns its path. Uses t.TempDir() for auto-cleanup. Does NOT chdir — the caller uses the returned path explicitly.

func SetupGitRepoWithHook

func SetupGitRepoWithHook(t *testing.T) string

SetupGitRepoWithHook creates a Git repo with a lore post-commit hook marker installed. Returns the repo path.

NOTE: hook content is hardcoded here and may drift from the actual hook installed by git.installHook (which reads from an embedded script). testutil cannot import git/ (import boundary). If the hook format changes, update this fixture accordingly.

func SetupLoreDir

func SetupLoreDir(t *testing.T) string

SetupLoreDir creates a minimal .lore/ structure (docs/, templates/, pending/) in a t.TempDir(). Does NOT chdir. Returns the temp dir path.

func SetupLoreDirWithDocs

func SetupLoreDirWithDocs(t *testing.T, docs []DocFixture) string

SetupLoreDirWithDocs creates .lore/ with pre-existing document files. Each DocFixture generates a properly formatted .md file in .lore/docs/. Returns the temp dir path.

func TestConfig

func TestConfig() *config.Config

func TestStreams

func TestStreams() (domain.IOStreams, *bytes.Buffer, *bytes.Buffer)

Types

type DocFixture

type DocFixture struct {
	Type string   // "decision", "feature", etc.
	Slug string   // "auth-strategy"
	Date string   // "2026-03-07"
	Tags []string // optional
	Body string   // optional — default body generated if empty
}

DocFixture describes a pre-existing document for test setup.

Jump to

Keyboard shortcuts

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