gittest

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Git

type Git igit.Git

Git provides utilities for verifying the state of a Git repository in test cases. It can check the current branch, ensure a branch name has a specific prefix, and assert that the latest commit message matches an expected value. These assertions are intended to be used within testing functions, where they provide helpful error messages upon failure to aid in diagnosing issues with repository state during test execution.

func (Git) AssertBranch

func (g Git) AssertBranch(t *testing.T, branch string)

AssertBranch confirms that the current git branch matches the specified branch name using the provided *testing.T. If the current branch does not match, it calls *testing.T's Fatal method to immediately fail the test with an appropriate error message.

func (Git) AssertBranchPrefix

func (g Git) AssertBranchPrefix(t *testing.T, prefix string)

AssertBranchPrefix verifies that the current branch name starts with the specified prefix, failing the test if it does not. It logs a fatal error with the testing.T if the current branch's name does not match the expected prefix. This function is intended to be used in test cases to ensure that branch naming conventions are followed.

func (Git) AssertCommit

func (g Git) AssertCommit(t *testing.T, c git.Commit)

AssertCommit verifies that the most recent commit in the repository has the expected message. It compares the actual commit message with the provided commit object and reports an error to the testing context if they do not match. This method is intended to be used in test cases to ensure that operations affecting the repository's commit history behave as expected.

func (Git) Cmd

func (g Git) Cmd(args ...string) (*exec.Cmd, []byte, error)

Cmd runs a git command with the provided arguments and returns the command along with its output and any encountered error. It wraps the execution of a git command in a way that can be easily used for testing purposes, capturing both the standard output and potential errors for assertions.

Jump to

Keyboard shortcuts

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