From b5c053b95c131d55d7077fbfa7104d60fa00a839 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Wed, 10 Feb 2021 16:48:25 +0200 Subject: [PATCH] refactor(stacks): remove utils --- api/exec/compose_stack_integration_test.go | 2 +- api/exec/utils.go | 24 ---------------------- api/exec/utils_test.go | 16 --------------- 3 files changed, 1 insertion(+), 41 deletions(-) delete mode 100644 api/exec/utils.go delete mode 100644 api/exec/utils_test.go diff --git a/api/exec/compose_stack_integration_test.go b/api/exec/compose_stack_integration_test.go index dcf9d9c24..687f88bb0 100644 --- a/api/exec/compose_stack_integration_test.go +++ b/api/exec/compose_stack_integration_test.go @@ -68,7 +68,7 @@ func Test_UpAndDown(t *testing.T) { } func containerExists(containerName string) bool { - cmd := exec.Command(osProgram("docker"), "ps", "-a", "-f", fmt.Sprintf("name=%s", containerName)) + cmd := exec.Command("docker", "ps", "-a", "-f", fmt.Sprintf("name=%s", containerName)) out, err := cmd.Output() if err != nil { diff --git a/api/exec/utils.go b/api/exec/utils.go deleted file mode 100644 index 75a896f65..000000000 --- a/api/exec/utils.go +++ /dev/null @@ -1,24 +0,0 @@ -package exec - -import ( - "os/exec" - "path/filepath" - "runtime" -) - -func osProgram(program string) string { - if runtime.GOOS == "windows" { - program += ".exe" - } - return program -} - -func programPath(rootPath, program string) string { - return filepath.Join(rootPath, osProgram(program)) -} - -// IsBinaryPresent returns true if corresponding program exists on PATH -func IsBinaryPresent(program string) bool { - _, err := exec.LookPath(program) - return err == nil -} diff --git a/api/exec/utils_test.go b/api/exec/utils_test.go deleted file mode 100644 index 38695488a..000000000 --- a/api/exec/utils_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package exec - -import ( - "testing" -) - -func Test_isBinaryPresent(t *testing.T) { - - if !IsBinaryPresent("docker") { - t.Error("expect docker binary to exist on the path") - } - - if IsBinaryPresent("executable-with-this-name-should-not-exist") { - t.Error("expect binary with a random name to be missing on the path") - } -}