Categorygithub.com/codeactual/testecho
modulepackage
0.1.4
Repository: https://github.com/codeactual/testecho.git
Documentation: pkg.go.dev

# README

testecho GoDoc Go Report Card Build Status

testecho is a program to assist test cases which assert the subject starts and ends processes as expected. Its flags allow selection of stdout, stderr, exit code, etc.

The testecho package provides functions to more easily run the CLI from test cases.

Usage

To install: go get -v github.com/codeactual/testecho/cmd/testecho

Examples

Display help

testecho --help

Print "out" to standard output:

testecho --stdout out

Same as above but also print "err" to standard error:

testecho --stdout out --stderr err

Same as above but also exit with code 7 instead of 0:

testecho --stdout out --stderr err --code 7

Same as above but also sleep for 5 seconds after printing:

testecho --stdout out --stderr err --code 7 --sleep 5

Spawn another testecho proecss, print its PID, and then sleep "forever" (10000 seconds):

testecho --spawn

Same as above but also print "err" to standard error:

testecho --spawn --stderr err

Print standard input:

echo "out" | testecho

Same as above but also print "err" to standard error:

echo "out" | testecho --stderr err

Same as above but also exit with code 7 instead of 0:

echo "out" | testecho --stderr err --code 7

Same as above but also sleep for 5 seconds after printing

echo "out" | testecho --stderr err --code 7 --sleep 5

Examples (in other projects)

Development

License

Mozilla Public License Version 2.0 (About, FAQ)

Contributing

  • Please feel free to submit issues, PRs, questions, and feedback.
  • Although this repository consists of snapshots extracted from a private monorepo using transplant, PRs are welcome. Standard GitHub workflows are still used.

# Packages

No description provided by the author

# Functions

NewCmd converts an Input into a command.
NewCmdArgs converts an Input value into argument strings for use in exec.Command.
NewCmdString returns a full command string based on the selected CLI input.
Which returns the absolute path to where the CLI would be installed based on GOPATH.

# Constants

DefaultStderr is the default value for the --stderr flag.
DefaultStdout is the default value for the --stdout flag.
DefaultStdoutFromStdin is the standard output emitted by testecho when it receives DefaultStdout via standard input.
DefaultStdoutFromStdinNested is the standard output emitted by testecho when it receives DefaultStdoutFromStdin via standard input.

# Structs

Input defines the CLI flags to use in a testecho invocation.