Documentation ¶
Index ¶
- Variables
- func CreateTemplateVersionSource(t *testing.T, responses *echo.Responses) string
- func New(t *testing.T, args ...string) (*clibase.Invocation, config.Root)
- func NewWithCommand(t *testing.T, cmd *clibase.Cmd, args ...string) (*clibase.Invocation, config.Root)
- func NormalizeGoldenFile(t *testing.T, byt []byte) []byte
- func Run(t *testing.T, inv *clibase.Invocation)
- func SetupConfig(t *testing.T, client *codersdk.Client, root config.Root)
- func Start(t *testing.T, inv *clibase.Invocation)
- func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *clibase.Cmd, cases []CommandHelpCase)
- type CommandHelpCase
- type ErrorWaiter
Constants ¶
This section is empty.
Variables ¶
var UpdateGoldenFiles = flag.Bool("update", false, "update .golden files")
UpdateGoldenFiles indicates golden files should be updated. To update the golden files: make update-golden-files
Functions ¶
func CreateTemplateVersionSource ¶ added in v0.4.0
CreateTemplateVersionSource writes the echo provisioner responses into a new temporary testing directory.
func New ¶
New creates a CLI instance with a configuration pointed to a temporary testing directory.
func NewWithCommand ¶ added in v0.21.0
func NormalizeGoldenFile ¶ added in v0.24.1
NormalizeGoldenFile replaces any strings that are system or timing dependent with a placeholder so that the golden files can be compared with a simple equality check.
func Run ¶ added in v0.21.0
func Run(t *testing.T, inv *clibase.Invocation)
Run runs the command and asserts that there is no error.
func SetupConfig ¶
SetupConfig applies the URL and SessionToken of the client to the config.
func Start ¶ added in v0.19.0
func Start(t *testing.T, inv *clibase.Invocation)
Start runs the command in a goroutine and cleans it up when the test completed.
func TestCommandHelp ¶ added in v0.24.1
func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *clibase.Cmd, cases []CommandHelpCase)
TestCommandHelp will test the help output of the given commands using golden files.
Types ¶
type CommandHelpCase ¶ added in v0.24.1
func DefaultCases ¶ added in v0.24.1
func DefaultCases() []CommandHelpCase
type ErrorWaiter ¶ added in v0.21.0
type ErrorWaiter struct {
// contains filtered or unexported fields
}
func StartWithWaiter ¶ added in v0.21.0
func StartWithWaiter(t *testing.T, inv *clibase.Invocation) *ErrorWaiter
StartWithWaiter runs the command in a goroutine but returns the error instead of asserting it. This is useful for testing error cases.
func (*ErrorWaiter) Cancel ¶ added in v0.23.5
func (w *ErrorWaiter) Cancel()
func (*ErrorWaiter) RequireAs ¶ added in v0.21.0
func (w *ErrorWaiter) RequireAs(want interface{})
func (*ErrorWaiter) RequireContains ¶ added in v0.21.0
func (w *ErrorWaiter) RequireContains(s string)
func (*ErrorWaiter) RequireError ¶ added in v0.21.0
func (w *ErrorWaiter) RequireError()
func (*ErrorWaiter) RequireIs ¶ added in v0.21.0
func (w *ErrorWaiter) RequireIs(want error)
func (*ErrorWaiter) RequireSuccess ¶ added in v0.21.0
func (w *ErrorWaiter) RequireSuccess()
func (*ErrorWaiter) Wait ¶ added in v0.21.0
func (w *ErrorWaiter) Wait() error