diff options
author | caojoshua <cao.joshua@yahoo.com> | 2021-05-19 23:44:58 -0700 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-05 10:58:09 +1000 |
commit | 60468d2e174656675b8058df519b6547bc7ca62e (patch) | |
tree | 397ed7424f8f0ba4061206b4989804fa509e56c8 /pkg/commands/files_test.go | |
parent | cb78cf7de4798bf628cf726689d62b18da34a347 (diff) |
Edit command as user OS config option
Diffstat (limited to 'pkg/commands/files_test.go')
-rw-r--r-- | pkg/commands/files_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go index 20c18a9a0..ba2632997 100644 --- a/pkg/commands/files_test.go +++ b/pkg/commands/files_test.go @@ -720,6 +720,7 @@ func TestGitCommandRemoveUntrackedFiles(t *testing.T) { func TestEditFileCmdStr(t *testing.T) { type scenario struct { filename string + configEditCommand string command func(string, ...string) *exec.Cmd getenv func(string) string getGitConfigValue func(string) (string, error) @@ -729,6 +730,7 @@ func TestEditFileCmdStr(t *testing.T) { scenarios := []scenario{ { "test", + "", func(name string, arg ...string) *exec.Cmd { return secureexec.Command("exit", "1") }, @@ -744,6 +746,25 @@ func TestEditFileCmdStr(t *testing.T) { }, { "test", + "nano", + func(name string, args ...string) *exec.Cmd { + assert.Equal(t, "which", name) + return secureexec.Command("echo") + }, + func(env string) string { + return "" + }, + func(cf string) (string, error) { + return "", nil + }, + func(cmdStr string, err error) { + assert.NoError(t, err) + assert.Equal(t, "nano \"test\"", cmdStr) + }, + }, + { + "test", + "", func(name string, arg ...string) *exec.Cmd { assert.Equal(t, "which", name) return secureexec.Command("exit", "1") @@ -761,6 +782,7 @@ func TestEditFileCmdStr(t *testing.T) { }, { "test", + "", func(name string, arg ...string) *exec.Cmd { assert.Equal(t, "which", name) return secureexec.Command("exit", "1") @@ -781,6 +803,7 @@ func TestEditFileCmdStr(t *testing.T) { }, { "test", + "", func(name string, arg ...string) *exec.Cmd { assert.Equal(t, "which", name) return secureexec.Command("exit", "1") @@ -802,6 +825,7 @@ func TestEditFileCmdStr(t *testing.T) { }, { "test", + "", func(name string, arg ...string) *exec.Cmd { assert.Equal(t, "which", name) return secureexec.Command("echo") @@ -819,6 +843,7 @@ func TestEditFileCmdStr(t *testing.T) { }, { "file/with space", + "", func(name string, args ...string) *exec.Cmd { assert.Equal(t, "which", name) return secureexec.Command("echo") @@ -838,6 +863,7 @@ func TestEditFileCmdStr(t *testing.T) { for _, s := range scenarios { gitCmd := NewDummyGitCommand() + gitCmd.Config.GetUserConfig().OS.EditCommand = s.configEditCommand gitCmd.OSCommand.Command = s.command gitCmd.OSCommand.Getenv = s.getenv gitCmd.getGitConfigValue = s.getGitConfigValue |