diff options
author | Anthony HAMON <anthony.hamon@iadvize.com> | 2018-08-27 22:41:46 +0200 |
---|---|---|
committer | Anthony HAMON <hamon.anth@gmail.com> | 2018-08-29 12:03:32 +0200 |
commit | 8247fd69c9ede8d829c83d41cfc847ce282b658a (patch) | |
tree | 7c3c6754575508da93921d3ad17e57349721f804 /pkg | |
parent | 983d0bd5868d2cd7f1aa4a793247de3dace60de4 (diff) |
add test for GetStashEntries
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/git_test.go | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 6deeee073..e709e747a 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -2,6 +2,7 @@ package commands import ( "io/ioutil" + "os/exec" "testing" "github.com/jesseduffield/lazygit/pkg/test" @@ -22,7 +23,53 @@ func newDummyGitCommand() *GitCommand { } } +func TestGitCommandGetStashEntries(t *testing.T) { + type scenario struct { + command func(string, ...string) *exec.Cmd + test func([]StashEntry) } + + scenarios := []scenario{ + { + func(string, ...string) *exec.Cmd { + return exec.Command("echo") + }, + func(entries []StashEntry) { + assert.Len(t, entries, 0) + }, + }, + { + func(string, ...string) *exec.Cmd { + return exec.Command("echo", "WIP on add-pkg-commands-test: 55c6af2 increase parallel build\nWIP on master: bb86a3f update github template") + }, + func(entries []StashEntry) { + expected := []StashEntry{ + { + 0, + "WIP on add-pkg-commands-test: 55c6af2 increase parallel build", + "WIP on add-pkg-commands-test: 55c6af2 increase parallel build", + }, + { + 1, + "WIP on master: bb86a3f update github template", + "WIP on master: bb86a3f update github template", + }, + } + + assert.Len(t, entries, 2) + assert.EqualValues(t, expected, entries) + }, + }, + } + + for _, s := range scenarios { + gitCmd := newDummyGitCommand() + gitCmd.OSCommand.command = s.command + + s.test(gitCmd.GetStashEntries()) + } +} + func TestGitCommandDiff(t *testing.T) { gitCommand := newDummyGitCommand() assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh")) |