49 lines
883 B
Go
49 lines
883 B
Go
package executor
|
|
|
|
import "testing"
|
|
|
|
var closeSELinux = []string{
|
|
"sed",
|
|
"-i",
|
|
"s/SELINUX=enforcing/SELINUX=disabled/g",
|
|
"/etc/selinux/config",
|
|
}
|
|
|
|
var callShellScript = []string{
|
|
"/bin/bash",
|
|
"/root/IdeaProjects/ProjectOctopus/agent-go/tmp/simple.sh",
|
|
}
|
|
|
|
var shutdownFirewalld = []string{
|
|
// wrong usage of &&
|
|
"systemctl", "stop", "firewalld", "&&", "systemctl", "disable", "firewalld",
|
|
}
|
|
|
|
var ifconfigCommand = []string{"ifconfig"}
|
|
|
|
func TestReadTimeOutput(t *testing.T) {
|
|
|
|
ReadTimeCommandExecutor(ifconfigCommand)
|
|
|
|
}
|
|
|
|
func TestAllCommandExecutor(t *testing.T) {
|
|
ok, result := AllCommandExecutor(shutdownFirewalld)
|
|
|
|
t.Logf("执行结果为 => %#v", ok)
|
|
t.Logf("执行日志为 => %#v", result)
|
|
|
|
}
|
|
|
|
func TestPureResultSingleExecute(t *testing.T) {
|
|
|
|
PureResultSingleExecute(closeSELinux)
|
|
|
|
}
|
|
|
|
func TestPipelineCommandExecutor(t *testing.T) {
|
|
|
|
PipelineCommandExecutor()
|
|
|
|
}
|