cliassert

package module
v0.0.0-...-425256f Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: MIT Imports: 5 Imported by: 0

README

cliassert

Helper functions to test cli tools

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdResult

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

CmdResult represents a command execution result

func ExecCommand

func ExecCommand(bin string, args ...string) CmdResult

ExecCommand executes the provided command and returns a CmdResult

func (CmdResult) AssertCode

func (r CmdResult) AssertCode(t *testing.T, code int) bool

AssertCode asserts that the command exit code matched the provided one

func (CmdResult) AssertError

func (r CmdResult) AssertError(t *testing.T) bool

AssertError asserts that the command failed

func (CmdResult) AssertErrorMatch

func (r CmdResult) AssertErrorMatch(t *testing.T, re interface{}) bool

AssertErrorMatch asserts that the command failed and its stderr matches the provided regexp

func (CmdResult) AssertSuccess

func (r CmdResult) AssertSuccess(t *testing.T) bool

AssertSuccess asserts that the command succeeded (0 exit code)

func (CmdResult) AssertSuccessMatch

func (r CmdResult) AssertSuccessMatch(t *testing.T, re interface{}) bool

AssertSuccessMatch asserts that the command succeeded and its stdout matches the provided regexp

func (CmdResult) Code

func (r CmdResult) Code() int

Code returns the command exit code

func (CmdResult) Stderr

func (r CmdResult) Stderr() string

Stderr returns the command stderr

func (CmdResult) Stdout

func (r CmdResult) Stdout() string

Stdout returns the command stdout

func (CmdResult) Success

func (r CmdResult) Success() bool

Success returns true if the command exit code is 0 and false otherwhise

type Command

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

Command defines a command executor

func NewCommand

func NewCommand() *Command

NewCommand returns a new Command

func (*Command) Exec

func (c *Command) Exec(bin string, args ...string) CmdResult

Exec executes the provided command and returns a CmdResult

func (*Command) SetStdin

func (c *Command) SetStdin(stdin string)

SetStdin sets the stdin for the command to execute

Jump to

Keyboard shortcuts

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