Documentation ¶
Overview ¶
Package testsuite is a collection of utilities for integration/unit testing in golang.
Index ¶
- Variables
- func SharedDir(t *testing.T, id string) *paths.Path
- type Environment
- func (e *Environment) CleanUp()
- func (e *Environment) Download(rawURL string) *paths.Path
- func (e *Environment) Extract(archive *paths.Path) *paths.Path
- func (env *Environment) HTTPServeFile(port uint16, path *paths.Path) *url.URL
- func (e *Environment) RegisterCleanUpCallback(newCleanUp func())
- func (e *Environment) RootDir() *paths.Path
- func (e *Environment) SharedDownloadsDir() *paths.Path
- func (e *Environment) T() *testing.T
Constants ¶
This section is empty.
Variables ¶
var ProjectName = "go-testsuite"
ProjectName is the prefix used in the test temp files
Functions ¶
Types ¶
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment is a test environment for the test suite.
func NewEnvironment ¶
func NewEnvironment(t *testing.T) *Environment
NewEnvironment creates a new test environment.
func (*Environment) Download ¶
func (e *Environment) Download(rawURL string) *paths.Path
Download downloads a file from a URL and returns the path to the downloaded file. The file is saved and cached in a shared downloads directory. If the file already exists, it is not downloaded again.
func (*Environment) Extract ¶
func (e *Environment) Extract(archive *paths.Path) *paths.Path
Extract extracts a tarball to a directory named as the archive with the "_content" suffix added. Returns the path to the directory.
func (*Environment) HTTPServeFile ¶
func (env *Environment) HTTPServeFile(port uint16, path *paths.Path) *url.URL
HTTPServeFile spawn an http server that serve a single file. The server is started on the given port. The URL to the file and a cleanup function are returned.
func (*Environment) RegisterCleanUpCallback ¶
func (e *Environment) RegisterCleanUpCallback(newCleanUp func())
RegisterCleanUpCallback adds a clean up function to the clean up chain
func (*Environment) RootDir ¶
func (e *Environment) RootDir() *paths.Path
RootDir returns the root dir of the environment.
func (*Environment) SharedDownloadsDir ¶
func (e *Environment) SharedDownloadsDir() *paths.Path
SharedDownloadsDir return the shared directory for downloads