diff --git a/agent-go/executor/BasicFunction.go b/agent-go/executor/BasicFunction.go index 704dff7..68b5533 100644 --- a/agent-go/executor/BasicFunction.go +++ b/agent-go/executor/BasicFunction.go @@ -15,7 +15,7 @@ func BasicCommandExists(commandName string) bool { cmd := exec.Command("command", "-v", commandName) err := cmd.Run() if err != nil { - log.DebugF("指令 %s 不存在", commandName) + log.DebugF("指令 %s 不存在 => %s", commandName, err.Error()) return false } else { return true diff --git a/agent-go/executor/BasicFunction_test.go b/agent-go/executor/BasicFunction_test.go index 8ffa992..aebcd50 100644 --- a/agent-go/executor/BasicFunction_test.go +++ b/agent-go/executor/BasicFunction_test.go @@ -2,6 +2,7 @@ package executor import ( "github.com/magiconair/properties/assert" + "strconv" "testing" ) @@ -57,3 +58,11 @@ func TestBasicSystemdUp(t *testing.T) { t.Logf("result ok is %v resultLog is %v", ok, resultLog) } + +func TestBasicCommandExists(t *testing.T) { + + exists := BasicCommandExists("docker-compose") + + t.Logf("command exists is => %s", strconv.FormatBool(exists)) + +} diff --git a/agent-go/executor/FunctionalExecutor_test.go b/agent-go/executor/FunctionalExecutor_test.go index 69652f2..7a92be1 100644 --- a/agent-go/executor/FunctionalExecutor_test.go +++ b/agent-go/executor/FunctionalExecutor_test.go @@ -34,6 +34,11 @@ var wgetCommand = []string{ "/home/wdd/IdeaProjects/ProjectOctopus/agent-go/executor/script/123", } +var echoPathCommand = []string{ + "echo", + "$PATH", +} + var pipelineCommandFalse = []string{ "ls", "/etc", @@ -67,7 +72,7 @@ func TestReadTimeOutput(t *testing.T) { } func TestAllCommandExecutor(t *testing.T) { - ok, result := AllCommandExecutor(wgetCommand) + ok, result := AllCommandExecutor(echoPathCommand) t.Logf("执行结果为 => %#v", ok) t.Logf("执行日志为 => %#v", result)