testutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package testutil creates real on-disk git repositories for integration tests of monorel's higher layers.

Each helper takes a *testing.T and returns a TestRepo bound to t.TempDir() so cleanup is automatic. Operations panic on failure via t.Fatal — callers don't need to thread errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestRepo

type TestRepo struct {
	Dir string

	// Repo is the [git.Exec] bound to Dir, ready to pass into
	// monorel's higher-layer code under test.
	Repo *git.Exec
	// contains filtered or unexported fields
}

TestRepo is a real git repo in a temp directory, populated by the builder methods on this type.

func NewRepo

func NewRepo(t *testing.T) *TestRepo

NewRepo creates a fresh git repo in t.TempDir() with deterministic committer metadata (author=test, email=test@test). An initial empty commit is made so HEAD is valid.

func (*TestRepo) AddCommit

func (r *TestRepo) AddCommit(message string, files ...string)

AddCommit stages and commits the given files under the supplied message. Files must already exist (use WriteFile first).

func (*TestRepo) HeadSHA

func (r *TestRepo) HeadSHA() string

HeadSHA returns the SHA of the current HEAD.

func (*TestRepo) Tag

func (r *TestRepo) Tag(name, message string)

Tag creates an annotated tag at HEAD. message is the annotation; pass an empty string for a lightweight tag (matches git CLI).

func (*TestRepo) WriteFile

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

WriteFile writes content to dir/<rel>, creating parent dirs.

Jump to

Keyboard shortcuts

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