framework

package
v2.10.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 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 framework provides helpers for end-to-end testing.

Package framework contains helpers for constructing repositories during end-to-end tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCurrentBranch

func AssertCurrentBranch(t *testing.T, repo *TestRepo, expected string)

AssertCurrentBranch verifies the repository is on the expected branch.

func AssertEqual

func AssertEqual(t *testing.T, expected, actual any)

AssertEqual compares two values for equality.

func AssertError

func AssertError(t *testing.T, err error)

AssertError fails the test if an error is not present.

func AssertErrorContains

func AssertErrorContains(t *testing.T, err error, expected string)

AssertErrorContains ensures an error is present and includes the expected text.

func AssertFalse

func AssertFalse(t *testing.T, condition bool, message string)

AssertFalse fails the test if the condition is true.

func AssertFileContains

func AssertFileContains(t *testing.T, repo *TestRepo, path, content string)

AssertFileContains checks that a file contains the expected content.

func AssertFileExists

func AssertFileExists(t *testing.T, repo *TestRepo, path string)

AssertFileExists checks that a file exists in the repository.

func AssertFileNotExists

func AssertFileNotExists(t *testing.T, repo *TestRepo, path string)

AssertFileNotExists checks that a file does not exist in the repository.

func AssertHelpfulError

func AssertHelpfulError(t *testing.T, output string)

AssertHelpfulError validates that an error message contains helpful guidance markers.

func AssertMultipleStringsInOutput

func AssertMultipleStringsInOutput(t *testing.T, output string, expected []string)

AssertMultipleStringsInOutput verifies that all expected substrings appear in the output.

func AssertNoError

func AssertNoError(t *testing.T, err error)

AssertNoError fails the test if an unexpected error is present.

func AssertNotEqual

func AssertNotEqual(t *testing.T, notExpected, actual any)

AssertNotEqual compares two values and fails if they are equal.

func AssertOutputContains

func AssertOutputContains(t *testing.T, output, expected string)

AssertOutputContains checks that output includes the expected substring.

func AssertTrue

func AssertTrue(t *testing.T, condition bool, message string)

AssertTrue fails the test if the condition is false.

func AssertWorktreeCount

func AssertWorktreeCount(t *testing.T, repo *TestRepo, expected int)

AssertWorktreeCount ensures the repository has the expected number of worktrees.

func AssertWorktreeCreated

func AssertWorktreeCreated(t *testing.T, output, branch string)

AssertWorktreeCreated verifies worktree creation output contains the expected branch name.

func AssertWorktreeExists

func AssertWorktreeExists(t *testing.T, repo *TestRepo, path string)

AssertWorktreeExists asserts that a worktree entry contains the provided path substring.

func AssertWorktreeNotExists

func AssertWorktreeNotExists(t *testing.T, repo *TestRepo, path string)

AssertWorktreeNotExists asserts that no worktree entry contains the provided path substring.

func WithTimeout

func WithTimeout(timeout time.Duration) func(cmd *exec.Cmd)

WithTimeout adds a timeout to an exec command for use in helpers.

Types

type TestEnvironment

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

TestEnvironment manages the temporary state for an end-to-end test run.

func NewTestEnvironment

func NewTestEnvironment(t *testing.T) *TestEnvironment

NewTestEnvironment builds a new test environment and compiles the wtp binary when needed.

func (*TestEnvironment) Cleanup

func (e *TestEnvironment) Cleanup()

Cleanup runs registered cleanup callbacks for the environment.

func (*TestEnvironment) CreateNonRepoDir

func (e *TestEnvironment) CreateNonRepoDir(name string) *TestRepo

CreateNonRepoDir creates a directory that is not initialized as a git repository.

func (*TestEnvironment) CreateTestRepo

func (e *TestEnvironment) CreateTestRepo(name string) *TestRepo

CreateTestRepo initializes a new git repository within the test environment.

func (*TestEnvironment) FileExists

func (*TestEnvironment) FileExists(path string) bool

FileExists checks whether a file exists relative to the test environment root.

func (*TestEnvironment) RunInDir

func (e *TestEnvironment) RunInDir(dir, command string, args ...string) string

RunInDir executes a command in the specified directory and returns combined output.

func (*TestEnvironment) RunWTP

func (e *TestEnvironment) RunWTP(args ...string) (string, error)

RunWTP executes the wtp binary with the provided arguments.

func (*TestEnvironment) TmpDir

func (e *TestEnvironment) TmpDir() string

TmpDir returns the temporary directory used by the test environment.

func (*TestEnvironment) WriteFile

func (e *TestEnvironment) WriteFile(path, content string)

WriteFile writes file contents relative to the test environment root.

type TestRepo

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

TestRepo wraps a git repository created inside the test environment.

func (*TestRepo) AddRemote

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

AddRemote adds a git remote to the repository.

func (*TestRepo) CheckoutBranch

func (r *TestRepo) CheckoutBranch(name string)

CheckoutBranch switches to the specified branch.

func (*TestRepo) CommitFile

func (r *TestRepo) CommitFile(filename, content, message string)

CommitFile writes a file and commits it with the provided message.

func (*TestRepo) CreateBranch

func (r *TestRepo) CreateBranch(name string)

CreateBranch creates a new branch in the repository.

func (*TestRepo) CreateRemoteBranch

func (r *TestRepo) CreateRemoteBranch(remote, branch string)

CreateRemoteBranch pushes a branch to the specified remote.

func (*TestRepo) CurrentBranch

func (r *TestRepo) CurrentBranch() string

CurrentBranch returns the currently checked-out branch name.

func (*TestRepo) GetBranchCommitHash

func (r *TestRepo) GetBranchCommitHash(branch string) string

GetBranchCommitHash returns the commit hash for the specified branch.

func (*TestRepo) GetCommitHash

func (r *TestRepo) GetCommitHash() string

GetCommitHash returns the HEAD commit hash.

func (*TestRepo) GitStatus

func (r *TestRepo) GitStatus() string

GitStatus returns the output of `git status --short` for the repository.

func (*TestRepo) HasFile

func (r *TestRepo) HasFile(path string) bool

HasFile reports whether a file exists relative to the repository root.

func (*TestRepo) ListWorktrees

func (r *TestRepo) ListWorktrees() []string

ListWorktrees returns the list of worktrees known to the repository.

func (*TestRepo) Path

func (r *TestRepo) Path() string

Path returns the filesystem path of the repository.

func (*TestRepo) ReadFile

func (r *TestRepo) ReadFile(path string) string

ReadFile returns the contents of a file relative to the repository root.

func (*TestRepo) RunWTP

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

RunWTP executes the wtp binary from the repository directory.

func (*TestRepo) WriteConfig

func (r *TestRepo) WriteConfig(content string)

WriteConfig writes a .wtp.yml configuration file into the repository.

Jump to

Keyboard shortcuts

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