Documentation ¶
Overview ¶
Package clitest contains common utilities and helpers for testing the CLI
Index ¶
- func ShouldFail() types.GomegaMatcher
- func WithCapturedOutput(f func()) string
- type MockRequestResponse
- type TempSettings
- func (tempSettings *TempSettings) AppendPostHandler(authToken string, combineHandlers ...MockRequestResponse)
- func (tempSettings TempSettings) AssertConfigRereadMatches(contents string)
- func (settings *TempSettings) Close() error
- func (tempSettings *TempSettings) NewFakeClient(endpoint, token string) *graphql.Client
- type TmpFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShouldFail ¶ added in v0.1.7868
func ShouldFail() types.GomegaMatcher
On Unix, we want to assert that processed exited with 255 On Windows, it should be -1.
func WithCapturedOutput ¶
func WithCapturedOutput(f func()) string
WithCapturedOutput will call the provided function and capture any output to stdout which is returned as a string.
Types ¶
type MockRequestResponse ¶
MockRequestResponse is a helpful type for mocking HTTP handlers.
type TempSettings ¶
TempSettings contains useful settings for testing the CLI
func WithTempSettings ¶
func WithTempSettings() *TempSettings
WithTempSettings should be called in a BeforeEach and returns a new TempSettings with everything setup for you
func (*TempSettings) AppendPostHandler ¶
func (tempSettings *TempSettings) AppendPostHandler(authToken string, combineHandlers ...MockRequestResponse)
AppendPostHandler stubs out the provided MockRequestResponse. When authToken is an empty string no token validation is performed.
func (TempSettings) AssertConfigRereadMatches ¶
func (tempSettings TempSettings) AssertConfigRereadMatches(contents string)
AssertConfigRereadMatches re-opens the config file and checks it's contents against the given string
func (*TempSettings) Close ¶ added in v0.1.7868
func (settings *TempSettings) Close() error
Close should be called in an AfterEach and cleans up the temp directory and server process
func (*TempSettings) NewFakeClient ¶
func (tempSettings *TempSettings) NewFakeClient(endpoint, token string) *graphql.Client
NewFakeClient returns a new *client.Client with the TestServer set and the provided endpoint, token.
type TmpFile ¶
TmpFile wraps a temporary file on disk for utility.
func OpenTmpFile ¶
OpenTmpFile will create a new temporary file in the provided directory with a name of the given path.