From 24de1565928cb24a043d65dcb63801a6bf418bb9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 29 Mar 2023 14:46:46 +0200 Subject: [PATCH] Fix windows tests Now that the tests run again, it turns out that they actually fail, so fix them. --- pkg/commands/oscommands/os_windows_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/commands/oscommands/os_windows_test.go b/pkg/commands/oscommands/os_windows_test.go index cf9c1e68a..acb971b59 100644 --- a/pkg/commands/oscommands/os_windows_test.go +++ b/pkg/commands/oscommands/os_windows_test.go @@ -6,6 +6,7 @@ package oscommands import ( "testing" + "github.com/cli/safeexec" "github.com/go-errors/errors" "github.com/stretchr/testify/assert" ) @@ -19,11 +20,13 @@ func TestOSCommandOpenFileWindows(t *testing.T) { test func(error) } + fullCmdPath, _ := safeexec.LookPath("cmd") + scenarios := []scenario{ { filename: "test", runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "test"}, "", errors.New("error")), + ExpectArgs([]string{fullCmdPath, "/c", "start", "", "test"}, "", errors.New("error")), test: func(err error) { assert.Error(t, err) }, @@ -31,7 +34,7 @@ func TestOSCommandOpenFileWindows(t *testing.T) { { filename: "test", runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "test"}, "", nil), + ExpectArgs([]string{fullCmdPath, "/c", "start", "", "test"}, "", nil), test: func(err error) { assert.NoError(t, err) }, @@ -39,7 +42,7 @@ func TestOSCommandOpenFileWindows(t *testing.T) { { filename: "filename with spaces", runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "filename with spaces"}, "", nil), + ExpectArgs([]string{fullCmdPath, "/c", "start", "", "filename with spaces"}, "", nil), test: func(err error) { assert.NoError(t, err) }, @@ -47,7 +50,7 @@ func TestOSCommandOpenFileWindows(t *testing.T) { { filename: "let's_test_with_single_quote", runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "let's_test_with_single_quote"}, "", nil), + ExpectArgs([]string{fullCmdPath, "/c", "start", "", "let's_test_with_single_quote"}, "", nil), test: func(err error) { assert.NoError(t, err) }, @@ -55,7 +58,7 @@ func TestOSCommandOpenFileWindows(t *testing.T) { { filename: "$USER.txt", runner: NewFakeRunner(t). - ExpectArgs([]string{"cmd", "/c", "start", "", "$USER.txt"}, "", nil), + ExpectArgs([]string{fullCmdPath, "/c", "start", "", "$USER.txt"}, "", nil), test: func(err error) { assert.NoError(t, err) },