This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
2018-09-19 15:22:51 +02:00
|
|
|
package openwrt
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2018-09-20 16:43:31 +02:00
|
|
|
func check(e error) {
|
|
|
|
if e != nil {
|
|
|
|
panic(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-19 15:22:51 +02:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|