Documentation ¶
Index ¶
- Variables
- type Expectation
- type SilentCmd
- func (s *SilentCmd) Exec() error
- func (s *SilentCmd) ExecTemplate(m map[string]string) error
- func (s *SilentCmd) Init()
- func (s *SilentCmd) Match(bufferString string) (match bool, expectation *Expectation)
- func (s *SilentCmd) Pipes() (i io.WriteCloser, o io.ReadCloser, e io.ReadCloser, err error)
- func (s *SilentCmd) Read(reader io.Reader)
- func (s *SilentCmd) ReadErr(reader io.Reader)
- func (s *SilentCmd) ReadToChannel(reader io.Reader, ch chan string)
- func (s *SilentCmd) Receive(w io.Writer) error
- func (s *SilentCmd) Write(l string, writer io.Writer) error
- type SilentCmds
Constants ¶
This section is empty.
Variables ¶
var (
Verbose bool
)
Functions ¶
This section is empty.
Types ¶
type Expectation ¶
Expectation is a structure that stores expected input and output coming from and to another application
type SilentCmd ¶
type SilentCmd struct { Cmd *exec.Cmd CmdString string `json:"cmd"` Expectations []*Expectation `json:"expectations"` ReceiveBuffer *bytes.Buffer ReadChan chan string ErrChan chan error ErrStringChan chan string // contains filtered or unexported fields }
SilentCmd is a command that will run silently this can be a regular command or it can be one that expects input from the user
func NewSilentCmd ¶
func NewSilentCmd() *SilentCmd
NewSilentCmd returns a new SilentCmd with all of its fields initialized (except expected cases)
func (*SilentCmd) ExecTemplate ¶
ExecTemplate parses a map replacing templated values in the command string
func (*SilentCmd) Match ¶
func (s *SilentCmd) Match(bufferString string) (match bool, expectation *Expectation)
Match checks the buffer string against expected cases, removing from the list when one is found
func (*SilentCmd) Pipes ¶
func (s *SilentCmd) Pipes() (i io.WriteCloser, o io.ReadCloser, e io.ReadCloser, err error)
Pipes returns stdin, stdout, and stderr of this command
func (*SilentCmd) ReadToChannel ¶
ReadToChannel reads from reader to the channel ch
func (*SilentCmd) Receive ¶
Receive loops on s.ReadChan, s.ErrChan, and s.ErrStringChan, selecting the first that occurs each iteration. If readchan receives then we are collecting input from stdout, if there is an error sent to s.ErrChan or s.ErrStringChan, we return the error. io.EOF is the expected case when no error actually occurred
type SilentCmds ¶
type SilentCmds []*SilentCmd
SilentCmds is a slice of *SilentCmd
func NewSilentCmdsFromJSON ¶
func NewSilentCmdsFromJSON(configData []byte) (SilentCmds, error)
NewSilentCmdsFromJSON loads a list of commands and inputs/outputs from a JSON file