From 65a24d70c332b0ff8f7e10999ab73260a3336fe7 Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Wed, 12 Sep 2018 20:43:03 +0200 Subject: [PATCH 1/5] commands/git : add tests on SquashPreviousTwoCommits --- pkg/commands/git.go | 5 ++-- pkg/commands/git_test.go | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 5744fa6aa..c200a688b 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -327,12 +327,11 @@ func (c *GitCommand) Push(branchName string, force bool) error { // retaining the message of the higher commit func (c *GitCommand) SquashPreviousTwoCommits(message string) error { // TODO: test this - err := c.OSCommand.RunCommand("git reset --soft HEAD^") - if err != nil { + if err := c.OSCommand.RunCommand("git reset --soft HEAD^"); err != nil { return err } // TODO: if password is required, we need to return a subprocess - return c.OSCommand.RunCommand("git commit --amend -m " + c.OSCommand.Quote(message)) + return c.OSCommand.RunCommand(fmt.Sprintf("git commit --amend -m %s", c.OSCommand.Quote(message))) } // SquashFixupCommit squashes a 'FIXUP' commit into the commit beneath it, diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index bda3ea225..0bcbdb7dd 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -953,6 +953,69 @@ func TestGitCommandPush(t *testing.T) { } } +func TestGitCommandSquashPreviousTwoCommits(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + } + + scenarios := []scenario{ + { + "Git reset triggers an error", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"reset", "--soft", "HEAD^"}, args) + + return exec.Command("exit", "1") + }, + func(err error) { + assert.NotNil(t, err) + }, + }, + { + "Git commit triggers an error", + func(cmd string, args ...string) *exec.Cmd { + if len(args) > 0 && args[0] == "reset" { + return exec.Command("echo") + } + + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"commit", "--amend", "-m", "test"}, args) + + return exec.Command("exit", "1") + }, + func(err error) { + assert.NotNil(t, err) + }, + }, + { + "Stash succeeded", + func(cmd string, args ...string) *exec.Cmd { + if len(args) > 0 && args[0] == "reset" { + return exec.Command("echo") + } + + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"commit", "--amend", "-m", "test"}, args) + + return exec.Command("echo") + }, + func(err error) { + assert.Nil(t, err) + }, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + s.test(gitCmd.SquashPreviousTwoCommits("test")) + }) + } +} + func TestGitCommandDiff(t *testing.T) { gitCommand := newDummyGitCommand() assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh")) From c92510ceba4d7b0f10ebf30c43206c7498e5f264 Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Wed, 12 Sep 2018 22:28:49 +0200 Subject: [PATCH 2/5] commands/git : add tests on SquashFixupCommit and refactor --- pkg/commands/git.go | 39 +++++++++++-------------- pkg/commands/git_test.go | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index c200a688b..8756a0483 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -337,38 +337,33 @@ func (c *GitCommand) SquashPreviousTwoCommits(message string) error { // SquashFixupCommit squashes a 'FIXUP' commit into the commit beneath it, // retaining the commit message of the lower commit func (c *GitCommand) SquashFixupCommit(branchName string, shaValue string) error { - var err error commands := []string{ - "git checkout -q " + shaValue, - "git reset --soft " + shaValue + "^", - "git commit --amend -C " + shaValue + "^", - "git rebase --onto HEAD " + shaValue + " " + branchName, + fmt.Sprintf("git checkout -q %s", shaValue), + fmt.Sprintf("git reset --soft %s^", shaValue), + fmt.Sprintf("git commit --amend -C %s^", shaValue), + fmt.Sprintf("git rebase --onto HEAD %s %s", shaValue, branchName), } - ret := "" for _, command := range commands { c.Log.Info(command) - output, err := c.OSCommand.RunCommandWithOutput(command) - ret += output - if err != nil { + + if output, err := c.OSCommand.RunCommandWithOutput(command); err != nil { + ret := output + // We are already in an error state here so we're just going to append + // the output of these commands + output, _ := c.OSCommand.RunCommandWithOutput(fmt.Sprintf("git branch -d %s", shaValue)) + ret += output + output, _ = c.OSCommand.RunCommandWithOutput(fmt.Sprintf("git checkout %s", branchName)) + ret += output + c.Log.Info(ret) - break + return errors.New(ret) } } - if err != nil { - // We are already in an error state here so we're just going to append - // the output of these commands - output, _ := c.OSCommand.RunCommandWithOutput("git branch -d " + shaValue) - ret += output - output, _ = c.OSCommand.RunCommandWithOutput("git checkout " + branchName) - ret += output - } - if err != nil { - return errors.New(ret) - } + return nil } -// CatFile obtain the contents of a file +// CatFile obtains the content of a file func (c *GitCommand) CatFile(fileName string) (string, error) { return c.OSCommand.RunCommandWithOutput("cat " + c.OSCommand.Quote(fileName)) } diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 0bcbdb7dd..bc0202df9 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -1016,6 +1016,69 @@ func TestGitCommandSquashPreviousTwoCommits(t *testing.T) { } } +func TestGitCommandSquashFixupCommit(t *testing.T) { + type scenario struct { + testName string + command func() (func(string, ...string) *exec.Cmd, *[][]string) + test func(*[][]string, error) + } + + scenarios := []scenario{ + { + "An error occurred with one of the sub git command", + func() (func(string, ...string) *exec.Cmd, *[][]string) { + cmdsCalled := [][]string{} + return func(cmd string, args ...string) *exec.Cmd { + cmdsCalled = append(cmdsCalled, args) + if len(args) > 0 && args[0] == "checkout" { + return exec.Command("exit", "1") + } + + return exec.Command("echo") + }, &cmdsCalled + }, + func(cmdsCalled *[][]string, err error) { + assert.NotNil(t, err) + assert.Len(t, *cmdsCalled, 3) + assert.EqualValues(t, *cmdsCalled, [][]string{ + {"checkout", "-q", "6789abcd"}, + {"branch", "-d", "6789abcd"}, + {"checkout", "test"}, + }) + }, + }, + { + "Squash fixup succeeded", + func() (func(string, ...string) *exec.Cmd, *[][]string) { + cmdsCalled := [][]string{} + return func(cmd string, args ...string) *exec.Cmd { + cmdsCalled = append(cmdsCalled, args) + return exec.Command("echo") + }, &cmdsCalled + }, + func(cmdsCalled *[][]string, err error) { + assert.Nil(t, err) + assert.Len(t, *cmdsCalled, 4) + assert.EqualValues(t, *cmdsCalled, [][]string{ + {"checkout", "-q", "6789abcd"}, + {"reset", "--soft", "6789abcd^"}, + {"commit", "--amend", "-C", "6789abcd^"}, + {"rebase", "--onto", "HEAD", "6789abcd", "test"}, + }) + }, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + var cmdsCalled *[][]string + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command, cmdsCalled = s.command() + s.test(cmdsCalled, gitCmd.SquashFixupCommit("test", "6789abcd")) + }) + } +} + func TestGitCommandDiff(t *testing.T) { gitCommand := newDummyGitCommand() assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh")) From 3cf84a5af10e51bfb4c890731e417728ff62973f Mon Sep 17 00:00:00 2001 From: mingrammer Date: Fri, 14 Sep 2018 00:23:11 +0900 Subject: [PATCH 3/5] main: display an error message instead of panic when setup fails --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 890b69a7f..edf1e7207 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "log" "os" "path/filepath" "runtime" @@ -40,13 +41,13 @@ func main() { } appConfig, err := config.NewAppConfig("lazygit", version, commit, date, buildSource, debuggingFlag) if err != nil { - panic(err) + log.Fatal(err.Error()) } app, err := app.Setup(appConfig) if err != nil { app.Log.Error(err.Error()) - panic(err) + log.Fatal(err.Error()) } app.Gui.RunWithSubprocesses() From 91832f2c5e40b9ea00291ae82f66bd09585fa3bc Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Thu, 13 Sep 2018 21:27:35 +0200 Subject: [PATCH 4/5] commands/git : add tests, refactor a bit --- pkg/commands/git.go | 12 ++-- pkg/commands/git_test.go | 142 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 146 insertions(+), 8 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 8756a0483..0c7509b91 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -365,12 +365,12 @@ func (c *GitCommand) SquashFixupCommit(branchName string, shaValue string) error // CatFile obtains the content of a file func (c *GitCommand) CatFile(fileName string) (string, error) { - return c.OSCommand.RunCommandWithOutput("cat " + c.OSCommand.Quote(fileName)) + return c.OSCommand.RunCommandWithOutput(fmt.Sprintf("cat %s", c.OSCommand.Quote(fileName))) } // StageFile stages a file func (c *GitCommand) StageFile(fileName string) error { - return c.OSCommand.RunCommand("git add " + c.OSCommand.Quote(fileName)) + return c.OSCommand.RunCommand(fmt.Sprintf("git add %s", c.OSCommand.Quote(fileName))) } // StageAll stages all files @@ -385,13 +385,11 @@ func (c *GitCommand) UnstageAll() error { // UnStageFile unstages a file func (c *GitCommand) UnStageFile(fileName string, tracked bool) error { - var command string + command := "git rm --cached %s" if tracked { - command = "git reset HEAD " - } else { - command = "git rm --cached " + command = "git reset HEAD %s" } - return c.OSCommand.RunCommand(command + c.OSCommand.Quote(fileName)) + return c.OSCommand.RunCommand(fmt.Sprintf(command, c.OSCommand.Quote(fileName))) } // GitStatus returns the plaintext short status of the repo diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index bc0202df9..466fa0c55 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -825,6 +825,146 @@ func TestGitCommandUsingGpg(t *testing.T) { } } +func TestGitCommandCatFile(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "cat", cmd) + assert.EqualValues(t, []string{"test.txt"}, args) + + return exec.Command("echo", "-n", "test") + } + + o, err := gitCmd.CatFile("test.txt") + assert.NoError(t, err) + assert.Equal(t, "test", o) +} + +func TestGitCommandStageFile(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"add", "test.txt"}, args) + + return exec.Command("echo") + } + + assert.NoError(t, gitCmd.StageFile("test.txt")) +} + +func TestGitCommandUnstageFile(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + tracked bool + } + + scenarios := []scenario{ + { + "Remove an untracked file from staging", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"rm", "--cached", "test.txt"}, args) + + return exec.Command("echo") + }, + func(err error) { + assert.NoError(t, err) + }, + false, + }, + { + "Remove a tracked file from staging", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"reset", "HEAD", "test.txt"}, args) + + return exec.Command("echo") + }, + func(err error) { + assert.NoError(t, err) + }, + true, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + s.test(gitCmd.UnStageFile("test.txt", s.tracked)) + }) + } +} + +func TestGitCommandIsInMergeState(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(bool, error) + } + + scenarios := []scenario{ + { + "An error occurred when running status command", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + + return exec.Command("exit", "1") + }, + func(isInMergeState bool, err error) { + assert.Error(t, err) + assert.False(t, isInMergeState) + }, + }, + { + "Is not in merge state", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo") + }, + func(isInMergeState bool, err error) { + assert.False(t, isInMergeState) + assert.NoError(t, err) + }, + }, + { + "Command output contains conclude merge", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo", "'conclude merge'") + }, + func(isInMergeState bool, err error) { + assert.True(t, isInMergeState) + assert.NoError(t, err) + }, + }, + { + "Command output contains unmerged paths", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo", "'unmerged paths'") + }, + func(isInMergeState bool, err error) { + assert.True(t, isInMergeState) + assert.NoError(t, err) + }, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + s.test(gitCmd.IsInMergeState()) + }) + } +} + func TestGitCommandCommit(t *testing.T) { type scenario struct { testName string @@ -917,7 +1057,7 @@ func TestGitCommandPush(t *testing.T) { }, }, { - "Push with force enable", + "Push with force enabled", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) assert.EqualValues(t, []string{"push", "--force-with-lease", "-u", "origin", "test"}, args) From c1b7a216312b4ce75bdf984fda6f59d870183bd3 Mon Sep 17 00:00:00 2001 From: Anthony HAMON Date: Thu, 13 Sep 2018 21:44:26 +0200 Subject: [PATCH 5/5] commands/git : move tests --- pkg/commands/git_test.go | 280 +++++++++++++++++++-------------------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 466fa0c55..88ecaea66 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -825,146 +825,6 @@ func TestGitCommandUsingGpg(t *testing.T) { } } -func TestGitCommandCatFile(t *testing.T) { - gitCmd := newDummyGitCommand() - gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "cat", cmd) - assert.EqualValues(t, []string{"test.txt"}, args) - - return exec.Command("echo", "-n", "test") - } - - o, err := gitCmd.CatFile("test.txt") - assert.NoError(t, err) - assert.Equal(t, "test", o) -} - -func TestGitCommandStageFile(t *testing.T) { - gitCmd := newDummyGitCommand() - gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"add", "test.txt"}, args) - - return exec.Command("echo") - } - - assert.NoError(t, gitCmd.StageFile("test.txt")) -} - -func TestGitCommandUnstageFile(t *testing.T) { - type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - test func(error) - tracked bool - } - - scenarios := []scenario{ - { - "Remove an untracked file from staging", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"rm", "--cached", "test.txt"}, args) - - return exec.Command("echo") - }, - func(err error) { - assert.NoError(t, err) - }, - false, - }, - { - "Remove a tracked file from staging", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"reset", "HEAD", "test.txt"}, args) - - return exec.Command("echo") - }, - func(err error) { - assert.NoError(t, err) - }, - true, - }, - } - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd := newDummyGitCommand() - gitCmd.OSCommand.command = s.command - s.test(gitCmd.UnStageFile("test.txt", s.tracked)) - }) - } -} - -func TestGitCommandIsInMergeState(t *testing.T) { - type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - test func(bool, error) - } - - scenarios := []scenario{ - { - "An error occurred when running status command", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) - - return exec.Command("exit", "1") - }, - func(isInMergeState bool, err error) { - assert.Error(t, err) - assert.False(t, isInMergeState) - }, - }, - { - "Is not in merge state", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) - return exec.Command("echo") - }, - func(isInMergeState bool, err error) { - assert.False(t, isInMergeState) - assert.NoError(t, err) - }, - }, - { - "Command output contains conclude merge", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) - return exec.Command("echo", "'conclude merge'") - }, - func(isInMergeState bool, err error) { - assert.True(t, isInMergeState) - assert.NoError(t, err) - }, - }, - { - "Command output contains unmerged paths", - func(cmd string, args ...string) *exec.Cmd { - assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) - return exec.Command("echo", "'unmerged paths'") - }, - func(isInMergeState bool, err error) { - assert.True(t, isInMergeState) - assert.NoError(t, err) - }, - }, - } - - for _, s := range scenarios { - t.Run(s.testName, func(t *testing.T) { - gitCmd := newDummyGitCommand() - gitCmd.OSCommand.command = s.command - s.test(gitCmd.IsInMergeState()) - }) - } -} - func TestGitCommandCommit(t *testing.T) { type scenario struct { testName string @@ -1219,6 +1079,146 @@ func TestGitCommandSquashFixupCommit(t *testing.T) { } } +func TestGitCommandCatFile(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "cat", cmd) + assert.EqualValues(t, []string{"test.txt"}, args) + + return exec.Command("echo", "-n", "test") + } + + o, err := gitCmd.CatFile("test.txt") + assert.NoError(t, err) + assert.Equal(t, "test", o) +} + +func TestGitCommandStageFile(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"add", "test.txt"}, args) + + return exec.Command("echo") + } + + assert.NoError(t, gitCmd.StageFile("test.txt")) +} + +func TestGitCommandUnstageFile(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(error) + tracked bool + } + + scenarios := []scenario{ + { + "Remove an untracked file from staging", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"rm", "--cached", "test.txt"}, args) + + return exec.Command("echo") + }, + func(err error) { + assert.NoError(t, err) + }, + false, + }, + { + "Remove a tracked file from staging", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"reset", "HEAD", "test.txt"}, args) + + return exec.Command("echo") + }, + func(err error) { + assert.NoError(t, err) + }, + true, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + s.test(gitCmd.UnStageFile("test.txt", s.tracked)) + }) + } +} + +func TestGitCommandIsInMergeState(t *testing.T) { + type scenario struct { + testName string + command func(string, ...string) *exec.Cmd + test func(bool, error) + } + + scenarios := []scenario{ + { + "An error occurred when running status command", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + + return exec.Command("exit", "1") + }, + func(isInMergeState bool, err error) { + assert.Error(t, err) + assert.False(t, isInMergeState) + }, + }, + { + "Is not in merge state", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo") + }, + func(isInMergeState bool, err error) { + assert.False(t, isInMergeState) + assert.NoError(t, err) + }, + }, + { + "Command output contains conclude merge", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo", "'conclude merge'") + }, + func(isInMergeState bool, err error) { + assert.True(t, isInMergeState) + assert.NoError(t, err) + }, + }, + { + "Command output contains unmerged paths", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"status", "--untracked-files=all"}, args) + return exec.Command("echo", "'unmerged paths'") + }, + func(isInMergeState bool, err error) { + assert.True(t, isInMergeState) + assert.NoError(t, err) + }, + }, + } + + for _, s := range scenarios { + t.Run(s.testName, func(t *testing.T) { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + s.test(gitCmd.IsInMergeState()) + }) + } +} + func TestGitCommandDiff(t *testing.T) { gitCommand := newDummyGitCommand() assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh"))