testutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil provides golden-file and temporary-directory helpers shared across gskill tests. It is imported only from _test.go files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitEnv added in v0.3.0

func GitEnv(extra ...string) []string

GitEnv returns a subprocess environment safe for running git against a test's own isolated fixture repository: os.Environ() with every ambient GIT_* variable stripped, plus extra appended. Without this, a git command invoked from inside a real git hook (as gotest-short runs under pre-commit) inherits GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE that git sets for the hook subprocess tree, so a fixture's "git init" in its own t.TempDir() silently operates on the enclosing gskill repository instead — under t.Parallel() this races real git state and can corrupt it.

This strips every GIT_* variable, unlike internal/git.sanitizedEnv's narrower repo-location-only allowlist: fixtures are local, no-auth repos that never need GIT_SSH_COMMAND/GIT_ASKPASS/GIT_CONFIG_*, so the blunter strip is safe here even though it would be wrong for gskill's own fetches.

func Golden

func Golden(t *testing.T, name string, got []byte)

Golden compares got against the golden file at testdata/<name>. When -update is set it rewrites the golden file instead of asserting equality, so golden files can be regenerated with "go test -update".

func TempProject

func TempProject(t *testing.T) string

TempProject returns an isolated temporary directory usable as a gskill project root for a single test. The directory is removed when the test ends.

func Update

func Update() bool

Update reports whether the -update flag was set for this test run.

Types

This section is empty.

Jump to

Keyboard shortcuts

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