Documentation ¶
Index ¶
- Constants
- Variables
- func NeedsExternalNetwork(t *testing.T)
- func NeedsGit(t *testing.T)
- type Helper
- func (h *Helper) Cd(dir string)
- func (h *Helper) Cleanup()
- func (h *Helper) DoRun(args []string) error
- func (h *Helper) Exist(path string) bool
- func (h *Helper) GetCommit(repo string) string
- func (h *Helper) GetFile(path string) io.ReadCloser
- func (h *Helper) GetTestFile(src string) io.ReadCloser
- func (h *Helper) GetTestFileString(src string) string
- func (h *Helper) Must(err error)
- func (h *Helper) MustExist(path string)
- func (h *Helper) MustNotExist(path string)
- func (h *Helper) Path(name string) string
- func (h *Helper) ReadLock() string
- func (h *Helper) ReadManifest() string
- func (h *Helper) Run(args ...string)
- func (h *Helper) RunGit(dir string, args ...string)
- func (h *Helper) RunGo(args ...string)
- func (h *Helper) Setenv(name, val string)
- func (h *Helper) ShouldExist(path string) error
- func (h *Helper) ShouldNotExist(path string) error
- func (h *Helper) TempCopy(dest, src string)
- func (h *Helper) TempDir(path string)
- func (h *Helper) TempFile(path, contents string)
- func (h *Helper) WriteTestFile(src string, content string) error
- type IntegrationTestCase
- func (tc *IntegrationTestCase) Cleanup()
- func (tc *IntegrationTestCase) CompareFile(goldenPath, working string)
- func (tc *IntegrationTestCase) CompareVendorPaths(gotVendorPaths []string)
- func (tc *IntegrationTestCase) InitialPath() string
- func (tc *IntegrationTestCase) WriteFile(src string, content string) error
- type IntegrationTestProject
- func (p *IntegrationTestProject) Cleanup()
- func (p *IntegrationTestProject) CompareImportPaths()
- func (p *IntegrationTestProject) CopyTree(src string)
- func (p *IntegrationTestProject) DoRun(args []string) error
- func (p *IntegrationTestProject) GetImportPaths() []string
- func (p *IntegrationTestProject) GetVendorGit(ip string)
- func (p *IntegrationTestProject) GetVendorPaths() []string
- func (p *IntegrationTestProject) Path(args ...string) string
- func (p *IntegrationTestProject) ProjPath(args ...string) string
- func (p *IntegrationTestProject) RecordImportPaths()
- func (p *IntegrationTestProject) RunGit(dir string, args ...string)
- func (p *IntegrationTestProject) RunGo(args ...string)
- func (p *IntegrationTestProject) TempDir(args ...string)
- func (p *IntegrationTestProject) TempProjDir(args ...string)
- func (p *IntegrationTestProject) VendorPath(args ...string) string
Constants ¶
const (
ProjectRoot string = "src/github.com/golang/notexist"
)
Variables ¶
var ( ExeSuffix string // ".exe" on Windows PrintLogs *bool = flag.Bool("logs", false, "log stdin/stdout of test commands") )
var (
UpdateGolden *bool = flag.Bool("update", false, "update golden files")
)
Functions ¶
func NeedsExternalNetwork ¶
NeedsExternalNetwork makes sure the tests needing external network will not be run when executing tests in short mode.
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper with utilities for testing.
func (*Helper) Cd ¶
Cd changes the current directory to the named directory. Note that using this means that the test must not be run in parallel with any other tests.
func (*Helper) DoRun ¶
DoRun runs the test go command, recording stdout and stderr and returning exit status.
func (*Helper) GetFile ¶
func (h *Helper) GetFile(path string) io.ReadCloser
GetTestFile reads a file into memory
func (*Helper) GetTestFile ¶
func (h *Helper) GetTestFile(src string) io.ReadCloser
GetTestFile reads a file from the testdata directory into memory. src is relative to ./testdata.
func (*Helper) GetTestFileString ¶
GetTestFileString reads a file from the testdata directory into memory. src is relative to ./testdata.
func (*Helper) MustNotExist ¶
MustNotExist fails if path exists.
func (*Helper) ReadManifest ¶
ReadManifest returns the manifest in the current directory.
func (*Helper) Setenv ¶
Setenv sets an environment variable to use when running the test go command.
func (*Helper) ShouldExist ¶
ShouldExist returns an error if path does not exist.
func (*Helper) ShouldNotExist ¶
ShouldNotExist returns an error if path exists.
func (*Helper) TempCopy ¶
TempCopy copies a temporary file from testdata into the temporary directory. dest is relative to the temp directory location, and src is relative to ./testdata.
type IntegrationTestCase ¶
type IntegrationTestCase struct { Commands [][]string `json:"commands"` GopathInitial map[string]string `json:"gopath-initial"` VendorInitial map[string]string `json:"vendor-initial"` VendorFinal []string `json:"vendor-final"` // contains filtered or unexported fields }
IntegrationTestCase manages a test case directory structure and content
func NewTestCase ¶
func NewTestCase(t *testing.T, name string) *IntegrationTestCase
func (*IntegrationTestCase) Cleanup ¶
func (tc *IntegrationTestCase) Cleanup()
Cleanup writes the resulting TestCase back to the directory, if the -update flag is set. During the test, comparisons made to the TestCase should write the result back to the TestCase when -update is enabled
func (*IntegrationTestCase) CompareFile ¶
func (tc *IntegrationTestCase) CompareFile(goldenPath, working string)
func (*IntegrationTestCase) CompareVendorPaths ¶
func (tc *IntegrationTestCase) CompareVendorPaths(gotVendorPaths []string)
func (*IntegrationTestCase) InitialPath ¶
func (tc *IntegrationTestCase) InitialPath() string
type IntegrationTestProject ¶
type IntegrationTestProject struct {
// contains filtered or unexported fields
}
IntegrationTestProject manages the "virtual" test project directory structure and content
func NewTestProject ¶
func NewTestProject(t *testing.T, initPath string) *IntegrationTestProject
func (*IntegrationTestProject) Cleanup ¶
func (p *IntegrationTestProject) Cleanup()
func (*IntegrationTestProject) CompareImportPaths ¶
func (p *IntegrationTestProject) CompareImportPaths()
Compare import paths before and after commands
func (*IntegrationTestProject) CopyTree ¶
func (p *IntegrationTestProject) CopyTree(src string)
func (*IntegrationTestProject) DoRun ¶
func (p *IntegrationTestProject) DoRun(args []string) error
func (*IntegrationTestProject) GetImportPaths ¶
func (p *IntegrationTestProject) GetImportPaths() []string
Collect final vendor paths at a depth of three levels
func (*IntegrationTestProject) GetVendorGit ¶
func (p *IntegrationTestProject) GetVendorGit(ip string)
func (*IntegrationTestProject) GetVendorPaths ¶
func (p *IntegrationTestProject) GetVendorPaths() []string
Collect final vendor paths at a depth of three levels
func (*IntegrationTestProject) Path ¶
func (p *IntegrationTestProject) Path(args ...string) string
func (*IntegrationTestProject) ProjPath ¶
func (p *IntegrationTestProject) ProjPath(args ...string) string
func (*IntegrationTestProject) RecordImportPaths ¶
func (p *IntegrationTestProject) RecordImportPaths()
func (*IntegrationTestProject) RunGit ¶
func (p *IntegrationTestProject) RunGit(dir string, args ...string)
func (*IntegrationTestProject) RunGo ¶
func (p *IntegrationTestProject) RunGo(args ...string)
func (*IntegrationTestProject) TempDir ¶
func (p *IntegrationTestProject) TempDir(args ...string)
func (*IntegrationTestProject) TempProjDir ¶
func (p *IntegrationTestProject) TempProjDir(args ...string)
func (*IntegrationTestProject) VendorPath ¶
func (p *IntegrationTestProject) VendorPath(args ...string) string