summaryrefslogtreecommitdiffstats
path: root/pkg/commands/files_test.go
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2021-10-09 14:53:43 +0900
committerJesse Duffield <jessedduffield@gmail.com>2021-10-17 11:00:20 +1100
commit1e50764b4db4313f191acc19580fd9920f8b6cdf (patch)
treeaa20e8e31aa3dd1ef68c956ad23527b4d08e4e14 /pkg/commands/files_test.go
parent9619d3447f6dba88a0ec0c621270130d0964907c (diff)
Fix tests
Diffstat (limited to 'pkg/commands/files_test.go')
-rw-r--r--pkg/commands/files_test.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go
index 19a014eaa..0d718a7bf 100644
--- a/pkg/commands/files_test.go
+++ b/pkg/commands/files_test.go
@@ -717,6 +717,8 @@ func TestGitCommandRemoveUntrackedFiles(t *testing.T) {
// TestEditFileCmdStr is a function.
func TestEditFileCmdStr(t *testing.T) {
+ gitCmd := NewDummyGitCommand()
+
type scenario struct {
filename string
configEditCommand string
@@ -761,7 +763,7 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "nano \"test\"", cmdStr)
+ assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
@@ -780,7 +782,7 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "nano \"test\"", cmdStr)
+ assert.Equal(t, "nano "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
@@ -825,7 +827,7 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "emacs \"test\"", cmdStr)
+ assert.Equal(t, "emacs "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
@@ -844,7 +846,7 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "vi \"test\"", cmdStr)
+ assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("test"), cmdStr)
},
},
{
@@ -863,7 +865,7 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "vi \"file/with space\"", cmdStr)
+ assert.Equal(t, "vi "+gitCmd.OSCommand.Quote("file/with space"), cmdStr)
},
},
{
@@ -882,13 +884,12 @@ func TestEditFileCmdStr(t *testing.T) {
},
func(cmdStr string, err error) {
assert.NoError(t, err)
- assert.Equal(t, "vim +1 \"open file/at line\"", cmdStr)
+ assert.Equal(t, "vim +1 "+gitCmd.OSCommand.Quote("open file/at line"), cmdStr)
},
},
}
for _, s := range scenarios {
- gitCmd := NewDummyGitCommand()
gitCmd.Config.GetUserConfig().OS.EditCommand = s.configEditCommand
gitCmd.Config.GetUserConfig().OS.EditCommandTemplate = s.configEditCommandTemplate
gitCmd.OSCommand.Command = s.command