testutil

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil provides helpers for creating temporary git repositories for end-to-end testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestRepo

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

TestRepo is a builder for creating temporary git repositories with controlled commit history, tags, and branches for e2e testing.

func NewTestRepo

func NewTestRepo(t testing.TB) *TestRepo

NewTestRepo creates and initializes a new git repository in a temporary directory.

func (*TestRepo) AddCommit

func (r *TestRepo) AddCommit(message string) string

AddCommit creates a new commit with the given message. A file named after the commit index is created to ensure each commit has changes. Returns the commit SHA.

func (*TestRepo) Checkout

func (r *TestRepo) Checkout(branch string)

Checkout switches HEAD to the given branch.

func (*TestRepo) CreateAnnotatedTag

func (r *TestRepo) CreateAnnotatedTag(name, sha, message string)

CreateAnnotatedTag creates an annotated tag pointing at the given SHA.

func (*TestRepo) CreateBranch

func (r *TestRepo) CreateBranch(name, sha string)

CreateBranch creates a new branch pointing at the given SHA and checks it out.

func (*TestRepo) CreateTag

func (r *TestRepo) CreateTag(name, sha string)

CreateTag creates a lightweight tag pointing at the given SHA.

func (*TestRepo) HeadSha

func (r *TestRepo) HeadSha() string

HeadSha returns the current HEAD commit SHA.

func (*TestRepo) MergeCommit

func (r *TestRepo) MergeCommit(message, otherSha string) string

MergeCommit creates a merge commit with two parents: the current HEAD and the given SHA. Returns the merge commit SHA.

func (*TestRepo) Path

func (r *TestRepo) Path() string

Path returns the repository root directory.

func (*TestRepo) WriteConfig

func (r *TestRepo) WriteConfig(content string)

WriteConfig writes a go-gitsemver.yml file in the repo root.

func (*TestRepo) WriteConfigAt

func (r *TestRepo) WriteConfigAt(relPath, content string)

WriteConfigAt writes a config file at a custom path relative to the repo root.

Jump to

Keyboard shortcuts

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