Movatterモバイル変換


[0]ホーム

URL:


clitest

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:29Imported by:0

Details

Repository

github.com/coder/coder

Links

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 gen/golden-files

Functions

funcCreateTemplateVersionSource

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

CreateTemplateVersionSource writes the echo provisioner responses into anew temporary testing directory.

funcHandlersOK

func HandlersOK(t *testing.T, cmd *serpent.Command)

HandlersOK asserts that all commands have a handler.Without a handler, the command has no default behavior. Even fornon-root commands (like 'groups' or 'users'), a handler is required.These handlers are likely just the 'help' handler, but this must beexplicitly set.

funcNew

func New(ttesting.TB, args ...string) (*serpent.Invocation,config.Root)

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

funcNewWithCommand

func NewWithCommand(ttesting.TB, cmd *serpent.Command, args ...string,) (*serpent.Invocation,config.Root)

funcRun

func Run(t *testing.T, inv *serpent.Invocation)

Run runs the command and asserts that there is no error.

funcSetupConfig

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

SetupConfig applies the URL and SessionToken of the client to the config.

funcStart

func Start(t *testing.T, inv *serpent.Invocation)

Start runs the command in a goroutine and cleans it up when the testcompleted.

funcStartWithAssertadded inv2.9.0

func StartWithAssert(t *testing.T, inv *serpent.Invocation, assertCallback func(t *testing.T, errerror))

funcTestCommandHelp

func TestCommandHelp(t *testing.T, getRoot func(t *testing.T) *serpent.Command, cases []CommandHelpCase)

TestCommandHelp will test the help output of the given commandsusing golden files.

funcTestGoldenFileadded inv2.10.0

func TestGoldenFile(t *testing.T, fileNamestring, actual []byte, replacements map[string]string)

TestGoldenFile will test the given bytes slice input against thegolden file with the given file name, optionally using the given replacements.

Types

typeCommandHelpCase

type CommandHelpCase struct {NamestringCmd  []string}

funcDefaultCases

func DefaultCases() []CommandHelpCase

typeErrorWaiter

type ErrorWaiter struct {// contains filtered or unexported fields}

funcStartWithWaiter

func StartWithWaiter(t *testing.T, inv *serpent.Invocation) *ErrorWaiter

StartWithWaiter runs the command in a goroutine but returns the error insteadof 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(sstring)

func (*ErrorWaiter)RequireError

func (w *ErrorWaiter) RequireError()

func (*ErrorWaiter)RequireIs

func (w *ErrorWaiter) RequireIs(wanterror)

func (*ErrorWaiter)RequireSuccess

func (w *ErrorWaiter) RequireSuccess()

func (*ErrorWaiter)Wait

func (w *ErrorWaiter) Wait()error

typeFakeSignalNotifieradded inv2.4.0

type FakeSignalNotifier struct {sync.Mutex// contains filtered or unexported fields}

funcNewFakeSignalNotifieradded inv2.4.0

func NewFakeSignalNotifier(t *testing.T) *FakeSignalNotifier

func (*FakeSignalNotifier)AssertStoppedadded inv2.4.0

func (f *FakeSignalNotifier) AssertStopped()

func (*FakeSignalNotifier)Notifyadded inv2.4.0

func (f *FakeSignalNotifier) Notify()

func (*FakeSignalNotifier)NotifyContextadded inv2.4.0

func (f *FakeSignalNotifier) NotifyContext(parentcontext.Context, signals ...os.Signal) (ctxcontext.Context, stopcontext.CancelFunc)

func (*FakeSignalNotifier)Stopadded inv2.4.0

func (f *FakeSignalNotifier) Stop()

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp