Documentation ¶
Index ¶
- Variables
- func RandomStackName() string
- func WriteYarnRCForTest(root string) error
- type Environment
- func (e *Environment) DeleteEnvironment()
- func (e *Environment) DeleteEnvironmentFallible() error
- func (e *Environment) DeleteIfNotFailed()
- func (e *Environment) GetCommandResults(command string, args ...string) (string, string, error)
- func (e *Environment) GetCommandResultsIn(dir string, command string, args ...string) (string, string, error)
- func (e *Environment) ImportDirectory(path string)
- func (e *Environment) LocalURL() string
- func (e *Environment) PathExists(p string) bool
- func (e *Environment) RunCommand(cmd string, args ...string) (string, string)
- func (e *Environment) RunCommandExpectError(cmd string, args ...string) (string, string)
- func (e *Environment) SetBackend(backend string)
- func (e *Environment) SetEnvVars(env ...string)
- func (e *Environment) WriteTestFile(filename string, contents string)
Constants ¶
This section is empty.
Variables ¶
var YarnInstallMutex sync.Mutex
Functions ¶
func RandomStackName ¶ added in v3.108.0
func RandomStackName() string
func WriteYarnRCForTest ¶
WriteYarnRCForTest writes a .yarnrc file which sets global configuration for every yarn inovcation. We use this to work around some test issues we see in Travis.
Types ¶
type Environment ¶
type Environment struct { *testing.T // HomePath is the PULUMI_HOME directory for the environment HomePath string // RootPath is a new temp directory where the environment starts. RootPath string // Current working directory, defaults to the root path. CWD string // Backend to use for commands Backend string // Environment variables to add to the environment for commands (`key=value`). Env []string // Passphrase for config secrets, if any Passphrase string // Set to true to turn off setting PULUMI_CONFIG_PASSPHRASE. NoPassphrase bool // Set to true to use the local Pulumi dev build from ~/.pulumi-dev/bin/pulumi which get from `make install` UseLocalPulumiBuild bool // Content to pass on stdin, if any Stdin io.Reader }
Environment is an extension of the testing.T type that provides support for a test environment on the local disk. The Environment has a root directory (e.g. a newly created temp folder) and a current working directory (to virtually change directories).
func NewEnvironment ¶
func NewEnvironment(t *testing.T) *Environment
NewEnvironment returns a new Environment object, located in a temp directory.
func NewGoEnvironment ¶
func NewGoEnvironment(t *testing.T) *Environment
NewGoEnvironment returns a new Environment object, located in a GOPATH temp directory.
func (*Environment) DeleteEnvironment ¶
func (e *Environment) DeleteEnvironment()
DeleteEnvironment deletes the environment's RootPath, and everything underneath it.
func (*Environment) DeleteEnvironmentFallible ¶ added in v3.12.0
func (e *Environment) DeleteEnvironmentFallible() error
DeleteEnvironment deletes the environment's RootPath, and everything underneath it. It tolerates failing to delete the environment.
func (*Environment) DeleteIfNotFailed ¶
func (e *Environment) DeleteIfNotFailed()
DeleteIfNotFailed deletes the environment's RootPath if the test hasn't failed. Otherwise keeps the files around for aiding debugging.
func (*Environment) GetCommandResults ¶
GetCommandResults runs the given command and args in the Environments CWD, returning STDOUT, STDERR, and the result of os/exec.Command{}.Run.
func (*Environment) GetCommandResultsIn ¶ added in v3.95.0
func (e *Environment) GetCommandResultsIn(dir string, command string, args ...string) (string, string, error)
GetCommandResultsIn runs the given command and args in the given directory, returning STDOUT, STDERR, and the result of os/exec.Command{}.Run.
func (*Environment) ImportDirectory ¶
func (e *Environment) ImportDirectory(path string)
ImportDirectory copies a folder into the test environment.
func (*Environment) LocalURL ¶
func (e *Environment) LocalURL() string
LocalURL returns a URL that uses the "fire and forget", storing its data inside the test folder (so multiple tests) may reuse stack names.
func (*Environment) PathExists ¶
func (e *Environment) PathExists(p string) bool
PathExists returns whether or not a file or directory exists relative to Environment's working directory.
func (*Environment) RunCommand ¶
func (e *Environment) RunCommand(cmd string, args ...string) (string, string)
RunCommand runs the command expecting a zero exit code, returning stdout and stderr.
func (*Environment) RunCommandExpectError ¶
func (e *Environment) RunCommandExpectError(cmd string, args ...string) (string, string)
RunCommandExpectError runs the command expecting a non-zero exit code, returning stdout and stderr.
func (*Environment) SetBackend ¶
func (e *Environment) SetBackend(backend string)
SetBackend sets the backend to use for commands in this environment.
func (*Environment) SetEnvVars ¶
func (e *Environment) SetEnvVars(env ...string)
SetEnvVars appends to the list of environment variables. According to https://pkg.go.dev/os/exec#Cmd.Env:
If Env contains duplicate environment keys, only the last value in the slice for each duplicate key is used.
So later values take precedence.
func (*Environment) WriteTestFile ¶
func (e *Environment) WriteTestFile(filename string, contents string)
WriteTestFile writes a new test file relative to the Environment's CWD with the given contents. Aborts the underlying test on any errors.
Directories ¶
Path | Synopsis |
---|---|
Package diagtest provides testing utilities for code that uses the common/diag package.
|
Package diagtest provides testing utilities for code that uses the common/diag package. |
Package iotest provides testing utilities for code that uses the io package.
|
Package iotest provides testing utilities for code that uses the io package. |