Documentation
¶
Index ¶
Constants ¶
const ( // TestCliPath expected to be on the PATH when tests run. TestCliPath = "testcli" FlagDisablePrompt = "disable-prompt" FlagExitOnErr = "exit-on-error" FlagFailOnStartup = "fail-on-startup" FlagNumRowsInDb = "num-rows-in-db" FlagRowToErrorOn = "row-to-error-on" )
Program name and flags needed for tests.
const ( CmdHelp = "help" CmdQuit = "quit" CmdEcho = "echo" CmdSleep = "sleep" CmdQuery = "query" )
All individual commands.
Variables ¶
var AllCommands = []string{ CmdHelp, CmdSleep, cmdVersion, CmdQuit, CmdEcho, cmdStatus, cmdSet, cmdPrint, CmdQuery, }
AllCommands can be used in help and validation.
Functions ¶
func MakeErrSentinelCommander ¶
func MakeErrSentinelCommander() *cmdrs.SimpleSentinelCommander
MakeErrSentinelCommander returns a sentinel commander with a command that's unknown to the testcli; it triggers an error when used.
func MakeOutSentinelCommander ¶
func MakeOutSentinelCommander() *cmdrs.SimpleSentinelCommander
MakeOutSentinelCommander returns a sentinel commander that has testcli echo something unique to the output.
func MakeSleepCommander ¶
func MakeSleepCommander(d time.Duration) *cmdrs.HoardingCommander
MakeSleepCommander Returns a command that makes the testcli sleep for the given duration. Used in testing timeouts.
Types ¶
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell parses stdin, executing anything that validates as a command. See AllCommands for a complete list of recognized commands. This code exists to drive tests of the cli package.
type SillyDb ¶
type SillyDb struct {
// contains filtered or unexported fields
}
SillyDb responds to a query by printing generated data. The data is sequential hex32 numbers (primary ids) paired with some fake data.
func NewSillyDb ¶
NewSillyDb returns a new instance.
func (*SillyDb) DoLookupQuery ¶
DoLookupQuery prints some lines to stdout, representing a query result.
func (*SillyDb) DoScanQuery ¶
DoScanQuery prints n lines to stdout, representing a query result.
func (*SillyDb) NumRowsInDb ¶
NumRowsInDb returns the row count.
func (*SillyDb) RowToErrorOn ¶
RowToErrorOn reports the row which ill cause an error if it is accessed.