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

testhelper

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testhelper creates real git repositories in t.TempDir() for use in integration tests of the git.Runner implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitWithRemote

func InitWithRemote(t *testing.T) (local *Repo, remote *Repo)

InitWithRemote creates a local repo plus a bare "origin" clone so fetch/push work.

Types

type Repo

type Repo struct {
	Path string // absolute path to the repo root
	// contains filtered or unexported fields
}

Repo is a real git repository created in a temp directory.

func Init

func Init(t *testing.T) *Repo

Init creates a new bare-minimum git repository in t.TempDir(). The repo has one commit on "main" and origin/HEAD pointing to main.

func RepoAt

func RepoAt(t *testing.T, path string) *Repo

RepoAt wraps an existing directory as a Repo for use in tests. Use this when you need a Repo handle for a path created by the Runner (e.g. a worktree added via WorktreeAdd).

func (*Repo) Commit

func (r *Repo) Commit(message string)

Commit adds a file and creates a commit, advancing HEAD.

func (*Repo) CreateBranch

func (r *Repo) CreateBranch(name string)

CreateBranch creates a new branch from HEAD without checking it out.

func (*Repo) GitCmd

func (r *Repo) GitCmd(args ...string)

GitCmd runs a git command in the repo directory, failing the test on error.

func (*Repo) WriteFile

func (r *Repo) WriteFile(name, content string)

WriteFile writes content to a file inside the repo (creating parent dirs as needed).

Jump to

Keyboard shortcuts

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