30 lines
563 B
Go
30 lines
563 B
Go
|
package openwrt
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func createMockExecutor(stdout string, stderr string, returnCode int) Executor {
|
||
|
return &mockExecutor{
|
||
|
stdout: stdout,
|
||
|
stderr: stderr,
|
||
|
returnCode: returnCode,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type mockExecutor struct {
|
||
|
stdout string
|
||
|
stderr string
|
||
|
returnCode int
|
||
|
}
|
||
|
|
||
|
func (e *mockExecutor) Run(command string, params ...string) *CommandResult {
|
||
|
log.Printf("executing '%s %s'", command, strings.Join(params, " "))
|
||
|
return &CommandResult{
|
||
|
Stderr: e.stderr,
|
||
|
Stdout: e.stdout,
|
||
|
ReturnCode: e.returnCode,
|
||
|
}
|
||
|
}
|