diff options
Diffstat (limited to 'pkg/commands/git_test.go')
-rw-r--r-- | pkg/commands/git_test.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 51188f14d..c132de98a 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -1539,6 +1539,7 @@ func TestGitCommandDiff(t *testing.T) { command func(string, ...string) *exec.Cmd file *File plain bool + cached bool } scenarios := []scenario{ @@ -1556,12 +1557,13 @@ func TestGitCommandDiff(t *testing.T) { Tracked: true, }, false, + false, }, { - "Default case", + "cached", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--color", "--cached", "--", "test.txt"}, args) return exec.Command("echo") }, @@ -1570,22 +1572,23 @@ func TestGitCommandDiff(t *testing.T) { HasStagedChanges: false, Tracked: true, }, + false, true, }, { - "All changes staged", + "plain", func(cmd string, args ...string) *exec.Cmd { assert.EqualValues(t, "git", cmd) - assert.EqualValues(t, []string{"diff", "--color", "--cached", "--", "test.txt"}, args) + assert.EqualValues(t, []string{"diff", "--", "test.txt"}, args) return exec.Command("echo") }, &File{ - Name: "test.txt", - HasStagedChanges: true, - HasUnstagedChanges: false, - Tracked: true, + Name: "test.txt", + HasStagedChanges: false, + Tracked: true, }, + true, false, }, { @@ -1602,6 +1605,7 @@ func TestGitCommandDiff(t *testing.T) { Tracked: false, }, false, + false, }, } @@ -1609,7 +1613,7 @@ func TestGitCommandDiff(t *testing.T) { t.Run(s.testName, func(t *testing.T) { gitCmd := NewDummyGitCommand() gitCmd.OSCommand.command = s.command - gitCmd.Diff(s.file, s.plain) + gitCmd.Diff(s.file, s.plain, s.cached) }) } } @@ -1730,7 +1734,7 @@ func TestGitCommandApplyPatch(t *testing.T) { t.Run(s.testName, func(t *testing.T) { gitCmd := NewDummyGitCommand() gitCmd.OSCommand.command = s.command - s.test(gitCmd.ApplyPatch("test")) + s.test(gitCmd.ApplyPatch("test", false, true)) }) } } |