Documentation
¶
Index ¶
- Variables
- func CreateTemplateVersionSource(t *testing.T, responses *echo.Responses) string
- func HandlersOK(t *testing.T, cmd *serpent.Command)
- func New(t testing.TB, args ...string) (*serpent.Invocation, config.Root)
- func NewWithCommand(t testing.TB, cmd *serpent.Command, args ...string) (*serpent.Invocation, config.Root)
- func Run(t *testing.T, inv *serpent.Invocation)
- func SetupConfig(t *testing.T, client *codersdk.Client, root config.Root)
- func Start(t *testing.T, inv *serpent.Invocation)
- func StartWithAssert(t *testing.T, inv *serpent.Invocation, ...)
- func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Command, ...)
- func TestGoldenFile(t *testing.T, fileName string, actual []byte, replacements map[string]string)
- type CommandHelpCase
- type ErrorWaiter
- type FakeSignalNotifier
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 gen/golden-files
Functions ¶
func CreateTemplateVersionSource ¶
CreateTemplateVersionSource writes the echo provisioner responses into a new temporary testing directory.
func HandlersOK ¶
HandlersOK asserts that all commands have a handler. Without a handler, the command has no default behavior. Even for non-root commands (like 'groups' or 'users'), a handler is required. These handlers are likely just the 'help' handler, but this must be explicitly set.
func New ¶
New creates a CLI instance with a configuration pointed to a temporary testing directory.
func NewWithCommand ¶
func Run ¶
func Run(t *testing.T, inv *serpent.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 ¶
func Start(t *testing.T, inv *serpent.Invocation)
Start runs the command in a goroutine and cleans it up when the test completed.
func StartWithAssert ¶ added in v2.9.0
func TestCommandHelp ¶
func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Command, cases []CommandHelpCase)
TestCommandHelp will test the help output of the given commands using golden files.
Types ¶
type CommandHelpCase ¶
func DefaultCases ¶
func DefaultCases() []CommandHelpCase
type ErrorWaiter ¶
type ErrorWaiter struct {
// contains filtered or unexported fields
}
func StartWithWaiter ¶
func StartWithWaiter(t *testing.T, inv *serpent.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 ¶
func (w *ErrorWaiter) Cancel()
func (*ErrorWaiter) RequireAs ¶
func (w *ErrorWaiter) RequireAs(want interface{})
func (*ErrorWaiter) RequireContains ¶
func (w *ErrorWaiter) RequireContains(s string)
func (*ErrorWaiter) RequireError ¶
func (w *ErrorWaiter) RequireError()
func (*ErrorWaiter) RequireIs ¶
func (w *ErrorWaiter) RequireIs(want error)
func (*ErrorWaiter) RequireSuccess ¶
func (w *ErrorWaiter) RequireSuccess()
func (*ErrorWaiter) Wait ¶
func (w *ErrorWaiter) Wait() error
type FakeSignalNotifier ¶ added in v2.4.0
func NewFakeSignalNotifier ¶ added in v2.4.0
func NewFakeSignalNotifier(t *testing.T) *FakeSignalNotifier
func (*FakeSignalNotifier) AssertStopped ¶ added in v2.4.0
func (f *FakeSignalNotifier) AssertStopped()
func (*FakeSignalNotifier) Notify ¶ added in v2.4.0
func (f *FakeSignalNotifier) Notify()
func (*FakeSignalNotifier) NotifyContext ¶ added in v2.4.0
func (f *FakeSignalNotifier) NotifyContext(parent context.Context, signals ...os.Signal) (ctx context.Context, stop context.CancelFunc)
func (*FakeSignalNotifier) Stop ¶ added in v2.4.0
func (f *FakeSignalNotifier) Stop()