clitest

package
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func CreateTemplateVersionSource(t *testing.T, responses *echo.Responses) string

CreateTemplateVersionSource writes the echo provisioner responses into a new temporary testing directory.

func New

func New(t *testing.T, args ...string) (*clibase.Invocation, config.Root)

New creates a CLI instance with a configuration pointed to a temporary testing directory.

func NewWithCommand added in v0.21.0

func NewWithCommand(
	t *testing.T, cmd *clibase.Cmd, args ...string,
) (*clibase.Invocation, config.Root)

func NormalizeGoldenFile added in v0.24.1

func NormalizeGoldenFile(t *testing.T, byt []byte) []byte

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

func SetupConfig(t *testing.T, client *codersdk.Client, root config.Root)

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

type CommandHelpCase struct {
	Name string
	Cmd  []string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL