diff options
author | Davyd McColl <davydm@gmail.com> | 2021-05-28 13:39:15 +0200 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-07-01 17:13:13 +1000 |
commit | eb10ddfccc7623df769c839c95c475588f566bb2 (patch) | |
tree | bc4f4b88bb4b5a472d5050e69564b50cd45ed4a8 /pkg/commands | |
parent | 22a6771e51b4c34d27b03071c88af2e7411f2371 (diff) |
:white_check_mark: add a test around ignoring whitespace
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/files_test.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/pkg/commands/files_test.go b/pkg/commands/files_test.go index 16583adc7..867b75e32 100644 --- a/pkg/commands/files_test.go +++ b/pkg/commands/files_test.go @@ -333,11 +333,12 @@ func TestGitCommandDiscardAllFileChanges(t *testing.T) { // TestGitCommandDiff is a function. func TestGitCommandDiff(t *testing.T) { type scenario struct { - testName string - command func(string, ...string) *exec.Cmd - file *models.File - plain bool - cached bool + testName string + command func(string, ...string) *exec.Cmd + file *models.File + plain bool + cached bool + ignoreWhitespace bool } scenarios := []scenario{ @@ -356,6 +357,7 @@ func TestGitCommandDiff(t *testing.T) { }, false, false, + false, }, { "cached", @@ -372,6 +374,7 @@ func TestGitCommandDiff(t *testing.T) { }, false, true, + false, }, { "plain", @@ -388,6 +391,7 @@ func TestGitCommandDiff(t *testing.T) { }, true, false, + false, }, { "File not tracked and file has no staged changes", @@ -404,6 +408,24 @@ func TestGitCommandDiff(t *testing.T) { }, false, false, + false, + }, + { + "Default case (ignore whitespace)", + func(cmd string, args ...string) *exec.Cmd { + assert.EqualValues(t, "git", cmd) + assert.EqualValues(t, []string{"diff", "--submodule", "--no-ext-diff", "--color=always", "-w", "--", "test.txt"}, args) + + return secureexec.Command("echo") + }, + &models.File{ + Name: "test.txt", + HasStagedChanges: false, + Tracked: true, + }, + false, + false, + true, }, } @@ -411,7 +433,7 @@ func TestGitCommandDiff(t *testing.T) { t.Run(s.testName, func(t *testing.T) { gitCmd := NewDummyGitCommand() gitCmd.OSCommand.Command = s.command - gitCmd.WorktreeFileDiff(s.file, s.plain, s.cached, false) + gitCmd.WorktreeFileDiff(s.file, s.plain, s.cached, s.ignoreWhitespace) }) } } |