testutil

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides test utilities for git-this-bread tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStdout

func CaptureStdout(fn func()) string

CaptureStdout captures stdout during the execution of fn.

Types

type TestRepo

type TestRepo struct {
	Path string
	// contains filtered or unexported fields
}

TestRepo is a helper for creating temporary git repositories in tests.

func NewTestRepo

func NewTestRepo(t testing.TB) *TestRepo

NewTestRepo creates a new temporary git repository and registers cleanup.

func (*TestRepo) AddRemote

func (r *TestRepo) AddRemote(name, url string)

AddRemote adds a remote with the given name and URL.

func (*TestRepo) Checkout

func (r *TestRepo) Checkout(name string)

Checkout switches to the given branch.

func (*TestRepo) Commit

func (r *TestRepo) Commit(message string)

Commit stages all changes and creates a commit with the given message.

func (*TestRepo) CommitAs

func (r *TestRepo) CommitAs(message, email, name string)

CommitAs stages all changes and creates a commit as the specified author.

func (*TestRepo) CreateBranch

func (r *TestRepo) CreateBranch(name string)

CreateBranch creates a new branch.

func (*TestRepo) Git

func (r *TestRepo) Git(args ...string) string

Git runs a git command in the repository directory.

func (*TestRepo) GitMayFail

func (r *TestRepo) GitMayFail(args ...string) (string, error)

GitMayFail runs a git command that may fail, returning output and error.

func (*TestRepo) Stage

func (r *TestRepo) Stage(name string)

Stage stages a file.

func (*TestRepo) Stash

func (r *TestRepo) Stash()

Stash creates a stash entry. There must be staged or unstaged changes.

func (*TestRepo) WriteFile

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

WriteFile creates a file with the given content in the repository.

Jump to

Keyboard shortcuts

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