fixtures

package module
v5.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

go-git-fixtures GoDoc Test OpenSSF Scorecard

git repository fixtures used by go-git

Adding new Fixtures

Adding new pack fixtures
  1. Get the .idx and .pack files from the repository:
git clone https://<repository>
cd <repository_name>
git checkout <REF>
git gc

ls .git/objects/pack/
  1. Copy them into /data.
  2. Add a new entry in fixtures.go:
{
	Tags:         []string{"packfile", "<TAG_TO_REFER_TO>"},
	PackfileHash: "<PACK_HASH>",
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Filesystem = embedfs.New(&data)

Functions

func EnsureIsBare

func EnsureIsBare(fs billy.Filesystem) error

EnsureIsBare overrides the config file with one where bare is true.

Types

type Fixture

type Fixture struct {
	URL          string
	Tags         []string
	Head         string
	PackfileHash string
	DotGitHash   string
	WorktreeHash string
	ObjectsCount int32
}

func (*Fixture) Clone added in v5.1.0

func (f *Fixture) Clone() *Fixture

func (*Fixture) DotGit

func (f *Fixture) DotGit(opts ...Option) billy.Filesystem

DotGit creates a new temporary directory and unpacks the repository .git directory into it. Multiple calls to DotGit returns different directories.

func (*Fixture) Idx

func (f *Fixture) Idx() billy.File

func (*Fixture) Is

func (f *Fixture) Is(tag string) bool

func (*Fixture) Packfile

func (f *Fixture) Packfile() billy.File

func (*Fixture) Rev

func (f *Fixture) Rev() billy.File

func (*Fixture) Worktree

func (f *Fixture) Worktree(opts ...Option) billy.Filesystem

type Fixtures

type Fixtures []*Fixture

func All

func All() Fixtures

func Basic

func Basic() Fixtures

func ByTag

func ByTag(tag string) Fixtures

func ByURL

func ByURL(url string) Fixtures

func (Fixtures) ByTag

func (g Fixtures) ByTag(tag string) Fixtures

func (Fixtures) ByURL

func (g Fixtures) ByURL(url string) Fixtures

func (Fixtures) Exclude

func (g Fixtures) Exclude(tag string) Fixtures

func (Fixtures) One

func (g Fixtures) One() *Fixture

func (Fixtures) Run

func (g Fixtures) Run(t *testing.T, test func(*testing.T, *Fixture))

Run calls test within a t.Run for each fixture in g.

type Option

type Option func(*options)

func WithMemFS

func WithMemFS() Option

WithMemFS returns the option of using memfs for the fs created for Fixtures.

func WithTargetDir

func WithTargetDir(dirName func() string) Option

WithTargetDir returns the option of using an OS-based filesystem based on a target dir. The target dir will be based on the name returned from dirName, which aligns with tempdir functions in different testing frameworks (e.g. t.TempDir, c.MkDir).

The caller is responsible for removing the dir from disk. Therefore, it is recommended to delegate that to the testing framework:

Go:

WithTargetDir(t.TempDir)

Check Framework:

WithTargetDir(c.Mkdir)

Directories

Path Synopsis
internal
tgz

Jump to

Keyboard shortcuts

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