From a66ab08431449a8fed746819ac7161c7a00e2923 Mon Sep 17 00:00:00 2001 From: Justin Hawkins Date: Tue, 28 Nov 2023 20:24:18 +1030 Subject: [PATCH] Maybe this --- download/download_test.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/download/download_test.go b/download/download_test.go index a2aa0ed..f5ba787 100644 --- a/download/download_test.go +++ b/download/download_test.go @@ -2,6 +2,7 @@ package download import ( "os" + "os/exec" "strings" "sync" "testing" @@ -364,26 +365,28 @@ Deleting original file The Greatest Shot In Television [2WoDQBhJCVQ].f140.m4a (p } func TestLookForExecutable(t *testing.T) { + cmdPath, err := exec.LookPath("sleep") + if err != nil { + t.Errorf("cannot run this test without knowing about sleep: %s", err) + t.FailNow() + } + cmd := "sleep" path, err := absPathToExecutable(cmd) if assert.NoError(t, err) { - if path != "/bin/sleep" && path != "/usr/bin/sleep" { - t.Errorf("bad path: %s", path) - } + assert.Equal(t, cmdPath, path) } + cmd = "/bin/sleep" path, err = absPathToExecutable(cmd) if assert.NoError(t, err) { - if path != "/bin/sleep" && path != "/usr/bin/sleep" { - t.Errorf("bad path: %s", path) - } + assert.Equal(t, cmdPath, path) } - cmd = "../../../../../bin/sleep" + + cmd = "../../../../.." + cmdPath path, err = absPathToExecutable(cmd) if assert.NoError(t, err) { - if path != "/bin/sleep" && path != "/usr/bin/sleep" { - t.Errorf("bad path: %s", path) - } + assert.Equal(t, cmdPath, path) } cmd = "./sleep" _, err = absPathToExecutable(cmd) @@ -393,9 +396,7 @@ func TestLookForExecutable(t *testing.T) { cmd = "./sleep" path, err = absPathToExecutable(cmd) if assert.NoError(t, err) { - if path != "/bin/sleep" && path != "/usr/bin/sleep" { - t.Errorf("bad path: %s", path) - } + assert.Equal(t, cmdPath, path) } }