Documentation
¶
Overview ¶
Package shelltest provides a fake shell.Runner and an in-memory shell.Store so backends can be tested without touching the real system.
Index ¶
- func Exit(c shell.Cmd, code int) error
- type Fake
- func (f *Fake) Commands() []string
- func (f *Fake) Count(cmd string) int
- func (f *Fake) KillGroup(pid int)
- func (f *Fake) LookPath(program string) error
- func (f *Fake) Output(c shell.Cmd) (string, error)
- func (f *Fake) ProcessIdentity(pid int) string
- func (f *Fake) ProcessName(pid int) string
- func (f *Fake) Ran(cmd string) bool
- func (f *Fake) Reset()
- func (f *Fake) Run(c shell.Cmd) error
- func (f *Fake) Start(c shell.Cmd) (int, error)
- type Proc
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Fake ¶
type Fake struct {
// Outputs maps a command string or program name to its stdout.
Outputs map[string]string
// Errors maps a command string or program name to the error it returns.
Errors map[string]error
// Missing lists programs LookPath reports as not installed.
Missing map[string]bool
// Names maps a PID to what ProcessName reports; absent PIDs report "".
Names map[int]string
// Identities overrides what ProcessIdentity reports for a PID; "" means
// the process is gone. Without an entry, a PID this fake started
// reports "fake-<pid>" and any other PID reports "".
Identities map[int]string
// Effects maps a program name to a side effect performed by a successful
// Run, so a fake behaves like the real tool (e.g. ffmpeg writing its
// output file).
Effects map[string]func(c shell.Cmd) error
Calls []shell.Cmd // every Run, Output and Start, in order
Started []shell.Cmd // successful Start calls only
Procs []Proc // successful Start calls, with the PID each returned
Killed []int // KillGroup calls
// contains filtered or unexported fields
}
Fake records every command and answers from scripted responses. Responses are looked up by the full command string (Cmd.String()) first, then by program name.
func New ¶
func New() *Fake
New returns an empty Fake: every command succeeds with no output and every program is installed.
func (*Fake) ProcessIdentity ¶
func (*Fake) ProcessName ¶
Click to show internal directories.
Click to hide internal directories.