testing

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT, MIT, + 1 more Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCLI

func NewCLI() *cli.SensuCli

NewCLI returns a SensuCLI instace with mocked values with json format

func NewMockCLI

func NewMockCLI() *cli.SensuCli

NewMockCLI return SensuCLI instance w/ mocked values

func RunCmd

func RunCmd(cmd *cobra.Command, args []string) (string, error)

RunCmd runs your SensuCLI command and returns any output and errors the command might have returned. Works with commands that have implemented Run or RunE hooks.

func SimpleSensuCLI

func SimpleSensuCLI(apiClient client.APIClient) *cli.SensuCli

SimpleSensuCLI return SensuCLI instance w/ given client & live config

Types

type FileCapture

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

FileCapture helps us write tests where we want to assert that something was written to STDOUT or STDERR.

Usage:

stdout := NewFileCapture(&os.Stdin)
stdout.Start()
fmt.Println("omgomgomg")
stdout.Stop()
assert.Equal("omgomgomg", stdout.Output())

func NewFileCapture

func NewFileCapture(f **os.File) FileCapture

NewFileCapture instantiates new FileCapture

func (*FileCapture) Output

func (fc *FileCapture) Output() string

Output exposes the data captured; only available after capture has stopped

func (*FileCapture) Start

func (fc *FileCapture) Start()

Start starts capturing data written to FileCapture#file

func (*FileCapture) Stop

func (fc *FileCapture) Stop()

Stop stops capturing and reads the data to the FileCaputre#output string

Jump to

Keyboard shortcuts

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