summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Taylor <ctaylorr@gmail.com>2020-02-01 17:10:31 -0500
committerJesse Duffield <jessedduffield@gmail.com>2020-02-02 11:29:22 +1100
commitc6cb90e8cad161c3636e7923bc34eae229955aea (patch)
treef07a7de6c15b01c6948082f8326f7f5275621217
parentfb156bcaacf26361a20e89626080c91b9b19e97e (diff)
verify that VISUAL,EDITOR,LGCC envvars are set for non-interactive commandsv0.14
-rw-r--r--pkg/commands/git_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index de9d2f996..3c90cc49a 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"os/exec"
+ "regexp"
"testing"
"time"
@@ -2101,6 +2102,37 @@ func TestGitCommandCreateFixupCommit(t *testing.T) {
}
}
+// TestGitCommandSkipEditorCommand confirms that SkipEditorCommand injects
+// environment variables that suppress an interactive editor
+func TestGitCommandSkipEditorCommand(t *testing.T) {
+ cmd := NewDummyGitCommand()
+
+ cmd.OSCommand.SetBeforeExecuteCmd(func(cmd *exec.Cmd) {
+ test.AssertContainsMatch(
+ t,
+ cmd.Env,
+ regexp.MustCompile("^VISUAL="),
+ "expected VISUAL to be set for a non-interactive external command",
+ )
+
+ test.AssertContainsMatch(
+ t,
+ cmd.Env,
+ regexp.MustCompile("^EDITOR="),
+ "expected EDITOR to be set for a non-interactive external command",
+ )
+
+ test.AssertContainsMatch(
+ t,
+ cmd.Env,
+ regexp.MustCompile("^LAZYGIT_CLIENT_COMMAND=EXIT_IMMEDIATELY$"),
+ "expected LAZYGIT_CLIENT_COMMAND to be set for a non-interactive external command",
+ )
+ })
+
+ cmd.RunSkipEditorCommand("true")
+}
+
func TestFindDotGitDir(t *testing.T) {
type scenario struct {
testName string