{"modulePath":"cdr.dev/coder-cli","version":"v1.39.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tcli\n\nPackage tcli provides a framework for CLI integration testing. Execute commands on the raw host or inside a docker container. Define custom Assertion types to extend test functionality.\n\n## Types\n\n```go\ntype Assertable struct {\n\t// contains filtered or unexported fields\n}\n```\nAssertable describes an initialized command ready to be run and asserted against.\n\n```go\nfunc (a *Assertable) Assert(t *testing.T, option ...Assertion)\n```\nAssert runs the Assertable and.\n\n```go\ntype Assertion func(t *testing.T, r *CommandResult)\n```\nAssertion specifies an assertion on the given CommandResult. Pass custom Assertion functions to cover special cases.\n\n```go\nfunc DurationGreaterThan(dur time.Duration) Assertion\n```\nDurationGreaterThan asserts that the command completed in greater than the given duration.\n\n```go\nfunc DurationLessThan(dur time.Duration) Assertion\n```\nDurationLessThan asserts that the command completed in less than the given duration.\n\n```go\nfunc Error() Assertion\n```\nError asserts that the command exited with a nonzero exit code.\n\n```go\nfunc ExitCodeIs(code int) Assertion\n```\nExitCodeIs asserts that the command exited with the given code.\n\n```go\nfunc GetResult(result **CommandResult) Assertion\n```\nGetResult offers an escape hatch from tcli The pointer passed as \"result\" will be assigned to the command's \\*CommandResult.\n\n```go\nfunc StderrEmpty() Assertion\n```\nStderrEmpty asserts that the command did not write any data to Stderr.\n\n```go\nfunc StderrJSONUnmarshal(target interface{}) Assertion\n```\nStderrJSONUnmarshal attempts to unmarshal stderr into the given target.\n\n```go\nfunc StderrMatches(pattern string) Assertion\n```\nStderrMatches asserts that Stderr contains a substring which matches the given regexp.\n\n```go\nfunc StdoutEmpty() Assertion\n```\nStdoutEmpty asserts that the command did not write any data to Stdout.\n\n```go\nfunc StdoutJSONUnmarshal(target interface{}) Assertion\n```\nStdoutJSONUnmarshal attempts to unmarshal stdout into the given target.\n\n```go\nfunc StdoutMatches(pattern string) Assertion\n```\nStdoutMatches asserts that Stdout contains a substring which matches the given regexp.\n\n```go\nfunc Success() Assertion\n```\nSuccess asserts that the command exited with an exit code of 0.\n\n```go\ntype CommandResult struct {\n\tStdout, Stderr []byte\n\tExitCode       int\n\tDuration       time.Duration\n}\n```\nCommandResult contains the aggregated result of a command execution.\n\n```go\ntype ContainerConfig struct {\n\tName       string\n\tImage      string\n\tBindMounts map[string]string\n}\n```\nContainerConfig describes the ContainerRunner configuration schema for initializing a testing environment.\n\n```go\ntype ContainerRunner struct {\n\t// contains filtered or unexported fields\n}\n```\nContainerRunner specifies a runtime container for performing command tests.\n\n```go\nfunc NewContainerRunner(ctx context.Context, config *ContainerConfig) (*ContainerRunner, error)\n```\nNewContainerRunner starts a new docker container for executing command tests.\n\n```go\nfunc (r *ContainerRunner) Close() error\n```\nClose kills and removes the command execution testing container.\n\n```go\nfunc (r *ContainerRunner) Run(ctx context.Context, command string) *Assertable\n```\nRun executes the given command in the runtime container with reasonable defaults. \"command\" is executed in a shell as an argument to \"sh -c\".\n\n```go\nfunc (r *ContainerRunner) RunCmd(cmd *exec.Cmd) *Assertable\n```\nRunCmd lifts the given \\*exec.Cmd into the runtime container.\n\n```go\ntype HostRunner struct{}\n```\nHostRunner executes command tests on the host, outside of a container.\n\n```go\nfunc (r *HostRunner) Close() error\n```\nClose is a noop for HostRunner.\n\n```go\nfunc (r *HostRunner) Run(ctx context.Context, command string) *Assertable\n```\nRun executes the given command on the host. \"command\" is executed in a shell as an argument to \"sh -c\".\n\n```go\nfunc (r *HostRunner) RunCmd(cmd *exec.Cmd) *Assertable\n```\nRunCmd executes the given \\*exec.Cmd on the host.\n\n","path":"cdr.dev/coder-cli/pkg/tcli","name":"tcli","synopsis":"Package tcli provides a framework for CLI integration testing.","isRedistributable":true}
