testutil

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureStdout

func CaptureStdout(fn func() error) (string, error)

CaptureStdout redirects stdout while running fn and returns the output as a string. If there's an error during capture, it returns the error, otherwise it returns the error returned by fn.

Types

type Fixture

type Fixture struct {
	MockController *gomock.Controller
	Client         *hcapi2_mock.MockClient
	ActionWaiter   *state.MockActionWaiter
	TokenEnsurer   *state.MockTokenEnsurer
}

Fixture provides affordances for testing CLI commands.

func NewFixture

func NewFixture(t *testing.T) *Fixture

NewFixture creates a new Fixture.

func (*Fixture) ExpectEnsureToken

func (f *Fixture) ExpectEnsureToken()

ExpectEnsureToken makes the mock TokenEnsurer expect a EnsureToken call.

func (*Fixture) Finish

func (f *Fixture) Finish()

Finish must be called after the test is finished, preferably via `defer` directly after creating the Fixture.

func (*Fixture) Run

func (f *Fixture) Run(cmd *cobra.Command, args []string) (string, error)

Run runs the given cobra command with the given arguments and returns stdout output and a potential error.

Jump to

Keyboard shortcuts

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