gittest

package
v0.1.0-beta6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gittest provides utilities for testing git repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmdAs

func CmdAs(ts *testscript.TestScript, neg bool, args []string)

CmdAs sets the author and committer of the commits that follow.

as 'User Name <user@example.com>'

func CmdAt

func CmdAt(ts *testscript.TestScript, neg bool, args []string)

CmdAt sets the author and commit time of the commits that follow.

at <YYYY-MM-DDTHH:MM:SS>

func CmdGit

func CmdGit(ts *testscript.TestScript, neg bool, args []string)

CmdGit runs a git command in the repository.

[!] git [args ...]

Types

type Config

type Config map[string]string

Config is a set of Git configuration values.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig is the default Git configuration for all test repositories.

func (Config) Env

func (c Config) Env() []string

Env generates a list of environment variable assignments that will have the same effect as setting these configuration values in a Git repository. This is suitable for passing to exec.Cmd.Env.

func (Config) EnvMap

func (c Config) EnvMap() map[string]string

EnvMap generates a map of environment variable assignments that will have the same effect as setting these configuration values in a Git repository.

type Fixture

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

Fixture is a temporary directory that contains a Git repository built from a testscript file.

func LoadFixtureFile

func LoadFixtureFile(path string) (_ *Fixture, err error)

LoadFixtureFile loads a fixture file from the given path. The fixture file is expected to be testscript file that runs a series of git commands to set up a Git repository.

func LoadFixtureScript

func LoadFixtureScript(script []byte) (_ *Fixture, err error)

LoadFixtureScript loads a fixture from the testscript. It has access to the following commands in addition to testscript defaults:

func (*Fixture) Cleanup

func (f *Fixture) Cleanup()

Cleanup removes the temporary directory created by the fixture.

func (*Fixture) Dir

func (f *Fixture) Dir() string

Dir returns the directory of the fixture.

Jump to

Keyboard shortcuts

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