Documentation ¶
Index ¶
Constants ¶
const ( // When this environ var is set to a value and running tests with -v flag, // then TestIpniRunner output is logged. EnvTestIpniRunnerOutput = "TEST_IPNI_RUNNER_OUTPUT" IndexerReadyMatch = "Indexer is ready" ProviderHasPeerMatch = "connected to peer successfully" ProviderReadyMatch = "admin http server listening" DhstoreReady = "Store opened." )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Execution ¶
type Execution struct { Name string Args []string Watchers []StdoutWatcher }
func NewExecution ¶
func (Execution) WithWatcher ¶
func (p Execution) WithWatcher(watcher StdoutWatcher) Execution
type StdoutWatcher ¶
type StdoutWatcher struct { Match string Signal chan struct{} }
StdoutWatcher is a helper for watching the stdout of a command for a specific string. It is used by TestIpniRunner to watch for specific output from the commands. The Signal channel will be sent on when the match string is found.
func NewStdoutWatcher ¶
func NewStdoutWatcher(match string) StdoutWatcher
type TestIpniRunner ¶
type TestIpniRunner struct { Ctx context.Context Dir string Env []string // contains filtered or unexported fields }
TestIpniRunner is a helper for running the indexer and other commands. TestIpniRunner is not specifically tied to the indexer, but is designed to be used to manage multiple processes in a test; and is therefore useful for testing the indexer, the dhstore, and providers, all in a temporary directory and with a test environment.
func NewTestIpniRunner ¶
NewTestIpniRunner creates a new TestIpniRunner for the given test, context, and temporary directory. It also takes a list of StdoutWatchers, which will be used to watch for specific output from the commands.
func (*TestIpniRunner) Run ¶
func (tr *TestIpniRunner) Run(name string, args ...string) []byte
Run runs a command and returns its output. This is useful for executing synchronous commands within the temporary environment.
func (*TestIpniRunner) Start ¶
func (tr *TestIpniRunner) Start(ex Execution) *exec.Cmd
Start starts a command and returns the command. This is useful for executing asynchronous commands within the temporary environment. It will watch the command's stdout for the given match string, and send on a watcher's channel when/if found.