integration

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RunFunc

type RunFunc func(prog string, newargs []string, outW, errW io.Writer, dir string, env []string) error

RunFunc defines the function signature for an integration test command to execute.

type TestCase

type TestCase struct {
	Commands      [][]string        `json:"commands"`
	ShouldFail    bool              `json:"should-fail"`
	ErrorExpected string            `json:"error-expected"`
	GopathInitial map[string]string `json:"gopath-initial"`
	VendorInitial map[string]string `json:"vendor-initial"`
	VendorFinal   []string          `json:"vendor-final"`
	InitPath      string            `json:"init-path"`

	RequiredFeatureFlag string `json:"feature"`
	// contains filtered or unexported fields
}

TestCase manages a test case directory structure and content

func NewTestCase

func NewTestCase(t *testing.T, dir, name string) *TestCase

NewTestCase creates a new TestCase.

func (*TestCase) CompareCmdFailure added in v0.5.0

func (tc *TestCase) CompareCmdFailure(gotFail bool)

CompareCmdFailure checks to see if the failure/success (in the sense of an exit code) was as expected by the test fixture.

func (*TestCase) CompareError

func (tc *TestCase) CompareError(err error, stderr string)

CompareError compares expected and actual stderr output.

func (*TestCase) CompareFile

func (tc *TestCase) CompareFile(goldenPath, working string)

CompareFile compares the golden file with the working result.

func (*TestCase) CompareOutput

func (tc *TestCase) CompareOutput(stdout string)

CompareOutput compares expected and actual stdout output.

func (*TestCase) CompareVendorPaths

func (tc *TestCase) CompareVendorPaths(gotVendorPaths []string)

CompareVendorPaths validates the vendor directory contents.

func (*TestCase) InitialPath

func (tc *TestCase) InitialPath() string

InitialPath represents the initial set of files in a project.

func (*TestCase) UpdateFile

func (tc *TestCase) UpdateFile(goldenPath, workingPath string)

UpdateFile updates the golden file with the working result.

func (*TestCase) UpdateOutput added in v0.3.2

func (tc *TestCase) UpdateOutput(stdout string)

UpdateOutput updates the golden file for stdout with the working result.

func (*TestCase) WriteFile

func (tc *TestCase) WriteFile(src string, content string) error

WriteFile writes a file using the default file permissions.

type TestProject

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

TestProject manages the "virtual" test project directory structure and content

func NewTestProject

func NewTestProject(t *testing.T, initPath, wd string, run RunFunc) *TestProject

NewTestProject initializes a new test's project directory.

func (*TestProject) Cleanup

func (p *TestProject) Cleanup()

Cleanup (remove) the test project's directory.

func (*TestProject) CompareImportPaths

func (p *TestProject) CompareImportPaths()

CompareImportPaths compares import paths before and after test commands.

func (*TestProject) CopyTree

func (p *TestProject) CopyTree(src string)

CopyTree recursively copies a source directory into the test project's directory.

func (*TestProject) DoRun

func (p *TestProject) DoRun(args []string) error

DoRun executes the integration test command against the test project.

func (*TestProject) GetImportPaths

func (p *TestProject) GetImportPaths() []string

GetImportPaths collect final vendor paths at a depth of three levels.

func (*TestProject) GetStderr

func (p *TestProject) GetStderr() string

GetStderr gets the Stderr output from test run.

func (*TestProject) GetStdout

func (p *TestProject) GetStdout() string

GetStdout gets the Stdout output from test run.

func (*TestProject) GetVendorGit

func (p *TestProject) GetVendorGit(ip string)

GetVendorGit populates the initial vendor directory for a test project.

func (*TestProject) GetVendorPaths

func (p *TestProject) GetVendorPaths() []string

GetVendorPaths collects final vendor paths at a depth of three levels.

func (*TestProject) Must

func (p *TestProject) Must(err error)

Must gives a fatal error if err is not nil.

func (*TestProject) Path

func (p *TestProject) Path(args ...string) string

Path to the test project directory.

func (*TestProject) ProjPath

func (p *TestProject) ProjPath(args ...string) string

ProjPath builds an import path for the test project.

func (*TestProject) RecordImportPaths

func (p *TestProject) RecordImportPaths()

RecordImportPaths takes a snapshot of the import paths before test is run.

func (*TestProject) RunGit

func (p *TestProject) RunGit(dir string, args ...string)

RunGit runs a git command, and expects it to succeed.

func (*TestProject) RunGo

func (p *TestProject) RunGo(args ...string)

RunGo runs a go command, and expects it to succeed.

func (*TestProject) Setenv

func (p *TestProject) Setenv(name, val string)

Setenv sets an environment variable to use when running the test go command.

func (*TestProject) TempDir

func (p *TestProject) TempDir(args ...string)

TempDir creates a temporary directory for the test project.

func (*TestProject) TempProjDir

func (p *TestProject) TempProjDir(args ...string)

TempProjDir builds the path to a package within the test project.

func (*TestProject) VendorPath

func (p *TestProject) VendorPath(args ...string) string

VendorPath lists the contents of the test project's vendor directory.

Jump to

Keyboard shortcuts

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