fixture

package
v11.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

Factory manages the Git setup for the entire test suite. For each scenario, it provides a standardized, empty Fixture consisting of a local and remote Git repository.

Setting up a Fixture is an expensive operation and has to be done for every scenario. As a performance optimization, Factory creates a fully set up Fixture (including the main branch and configuration) (the "memoized" environment) at the beginning of the test suite and makes copies of it for each scenario. Making copies of a fully set up Git repo is much faster than creating it from scratch. End-to-end tests run multi-threaded, all threads share a global Factory instance.

func NewFactory

func NewFactory(dir string) Factory

NewFactory provides a new FixtureFactory instance operating in the given directory.

func (*Factory) CreateFixture

func (self *Factory) CreateFixture(scenarioName string) Fixture

CreateFixture provides a new Fixture for the scenario with the given name.

type Fixture

type Fixture struct {
	// Dir defines the local folder in which this Fixture is stored.
	// This folder also acts as the HOME directory for tests using this Fixture.
	// It contains the global Git configuration to use in this test.
	Dir string

	// CoworkerRepo is the optional Git repository that is locally checked out at the coworker machine.
	CoworkerRepo *testruntime.TestRuntime `exhaustruct:"optional"`

	// DevRepo is the Git repository that is locally checked out at the developer machine.
	DevRepo testruntime.TestRuntime `exhaustruct:"optional"`

	// OriginRepo is the Git repository that simulates the origin repo (on GitHub).
	// If this value is nil, the current test setup has no origin.
	OriginRepo *testruntime.TestRuntime `exhaustruct:"optional"`

	// SecondWorktree is the directory that contains an additional workspace.
	// If this value is nil, the current test setup has no additional workspace.
	SecondWorktree *testruntime.TestRuntime `exhaustruct:"optional"`

	// SubmoduleRepo is the Git repository that simulates an external repo used as a submodule.
	// If this value is nil, the current test setup uses no submodules.
	SubmoduleRepo *testruntime.TestRuntime `exhaustruct:"optional"`

	// UpstreamRepo is the optional Git repository that contains the upstream for this environment.
	UpstreamRepo *testruntime.TestRuntime `exhaustruct:"optional"`
}

Fixture is a complete Git environment for a Cucumber scenario.

func CloneFixture

func CloneFixture(original Fixture, dir string) Fixture

CloneFixture provides a Fixture instance in the given directory, containing a copy of the given Fixture.

func NewStandardFixture

func NewStandardFixture(dir string) Fixture

NewStandardFixture provides a Fixture in the given directory, fully populated as a standardized setup for scenarios.

The origin repo has the initial branch checked out. Git repos cannot receive pushes of the currently checked out branch because that will change files in the current workspace. The tests don't use the initial branch.

func (*Fixture) AddCoworkerRepo

func (self *Fixture) AddCoworkerRepo()

AddCoworkerRepo adds a coworker repository.

func (*Fixture) AddSecondWorktree added in v11.1.0

func (self *Fixture) AddSecondWorktree(branch domain.LocalBranchName)

func (*Fixture) AddSubmoduleRepo

func (self *Fixture) AddSubmoduleRepo()

AddSubmodule adds a submodule repository.

func (*Fixture) AddUpstream

func (self *Fixture) AddUpstream()

AddUpstream adds an upstream repository.

func (*Fixture) Branches

func (self *Fixture) Branches() datatable.DataTable

Branches provides a tabular list of all branches in this Fixture.

func (Fixture) CommitTable

func (self Fixture) CommitTable(fields []string) datatable.DataTable

CommitTable provides a table for all commits in this Git environment containing only the given fields.

func (*Fixture) CreateCommits

func (self *Fixture) CreateCommits(commits []testgit.Commit)

CreateCommits creates the commits described by the given Gherkin table in this Git repository.

func (Fixture) CreateOriginBranch

func (self Fixture) CreateOriginBranch(name, parent string)

CreateOriginBranch creates a branch with the given name only in the origin directory.

func (Fixture) CreateTags

func (self Fixture) CreateTags(table *messages.PickleStepArgument_PickleTable)

CreateTags creates tags from the given gherkin table.

func (Fixture) Remove

func (self Fixture) Remove()

Remove deletes all files used by this Fixture from disk.

func (Fixture) TagTable

func (self Fixture) TagTable() datatable.DataTable

TagTable provides a table for all tags in this Git environment.

Jump to

Keyboard shortcuts

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