Documentation ¶
Index ¶
- type RunFunc
- type TestCase
- func (tc *TestCase) CompareCmdFailure(gotFail bool)
- func (tc *TestCase) CompareError(err error, stderr string)
- func (tc *TestCase) CompareFile(goldenPath, working string)
- func (tc *TestCase) CompareOutput(stdout string)
- func (tc *TestCase) CompareVendorPaths(gotVendorPaths []string)
- func (tc *TestCase) InitialPath() string
- func (tc *TestCase) UpdateFile(goldenPath, workingPath string)
- func (tc *TestCase) UpdateOutput(stdout string)
- func (tc *TestCase) WriteFile(src string, content string) error
- type TestProject
- func (p *TestProject) Cleanup()
- func (p *TestProject) CompareImportPaths()
- func (p *TestProject) CopyTree(src string)
- func (p *TestProject) DoRun(args []string) error
- func (p *TestProject) GetImportPaths() []string
- func (p *TestProject) GetStderr() string
- func (p *TestProject) GetStdout() string
- func (p *TestProject) GetVendorGit(ip string)
- func (p *TestProject) GetVendorPaths() []string
- func (p *TestProject) Must(err error)
- func (p *TestProject) Path(args ...string) string
- func (p *TestProject) ProjPath(args ...string) string
- func (p *TestProject) RecordImportPaths()
- func (p *TestProject) RunGit(dir string, args ...string)
- func (p *TestProject) RunGo(args ...string)
- func (p *TestProject) Setenv(name, val string)
- func (p *TestProject) TempDir(args ...string)
- func (p *TestProject) TempProjDir(args ...string)
- func (p *TestProject) VendorPath(args ...string) string
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 ¶
NewTestCase creates a new TestCase.
func (*TestCase) CompareCmdFailure ¶
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 ¶
CompareError compares expected and actual stderr output.
func (*TestCase) CompareFile ¶
CompareFile compares the golden file with the working result.
func (*TestCase) CompareOutput ¶
CompareOutput compares expected and actual stdout output.
func (*TestCase) CompareVendorPaths ¶
CompareVendorPaths validates the vendor directory contents.
func (*TestCase) InitialPath ¶
InitialPath represents the initial set of files in a project.
func (*TestCase) UpdateFile ¶
UpdateFile updates the golden file with the working result.
func (*TestCase) UpdateOutput ¶
UpdateOutput updates the golden file for stdout with the working result.
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.