Added Example tests with failure status for ExecAndStream
parent
ac8b70976b
commit
a1c0529fda
|
@ -27,7 +27,7 @@ func ExecAndStream(path string, command string, args []string) {
|
|||
err := cmd.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("cmd.Run() failed with %s\n", err)
|
||||
fmt.Printf("cmd.Run() failed with %s\n", err)
|
||||
}
|
||||
|
||||
outStr, errStr := string(stdoutBuf.Bytes()), string(stderrBuf.Bytes())
|
||||
|
|
|
@ -30,6 +30,27 @@ func ExampleExecAndStream() {
|
|||
// err:
|
||||
}
|
||||
|
||||
func ExampleExecAndStreamExecutableNotFound() {
|
||||
ExecAndStream("/", "testcommand", []string{"Hello"})
|
||||
// Output:
|
||||
// cmd.Run() failed with exec: "testcommand": executable file not found in $PATH
|
||||
//
|
||||
// out:
|
||||
//
|
||||
// err:
|
||||
}
|
||||
|
||||
func ExampleExecAndStreamError() {
|
||||
ExecAndStream("/", "man", []string{"Hello"})
|
||||
// Output:
|
||||
// cmd.Run() failed with exit status 16
|
||||
//
|
||||
// out:
|
||||
//
|
||||
// err:
|
||||
// No manual entry for Hello
|
||||
}
|
||||
|
||||
func TestExecAndGetLines(t *testing.T) {
|
||||
testCommand := "echo"
|
||||
testArguments := []string{"$'Line1\nLine2\nLine3'"}
|
||||
|
|
Loading…
Reference in New Issue