mirror of
https://github.com/edgebox-iot/edgeboxctl.git
synced 2026-09-25 14:20:56 +02:00
Added Example tests with failure status for ExecAndStream
This commit is contained in:
@@ -27,7 +27,7 @@ func ExecAndStream(path string, command string, args []string) {
|
|||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
|
||||||
if err != nil {
|
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())
|
outStr, errStr := string(stdoutBuf.Bytes()), string(stderrBuf.Bytes())
|
||||||
|
|||||||
@@ -30,6 +30,27 @@ func ExampleExecAndStream() {
|
|||||||
// err:
|
// 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) {
|
func TestExecAndGetLines(t *testing.T) {
|
||||||
testCommand := "echo"
|
testCommand := "echo"
|
||||||
testArguments := []string{"$'Line1\nLine2\nLine3'"}
|
testArguments := []string{"$'Line1\nLine2\nLine3'"}
|
||||||
|
|||||||
Reference in New Issue
Block a user