mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-09-16 09:16:26 +02:00
add test for StashDo and refactor StashDo method
This commit is contained in:
committed by
Anthony HAMON
parent
85012dbc8f
commit
99840d8fc4
@@ -106,7 +106,7 @@ func (c *GitCommand) GetStatusFiles() []File {
|
||||
|
||||
// StashDo modify stash
|
||||
func (c *GitCommand) StashDo(index int, method string) error {
|
||||
return c.OSCommand.RunCommand("git stash " + method + " stash@{" + fmt.Sprint(index) + "}")
|
||||
return c.OSCommand.RunCommand(fmt.Sprintf("git stash %s stash@{%d}", method, index))
|
||||
}
|
||||
|
||||
// StashSave save stash
|
||||
|
@@ -161,6 +161,18 @@ func TestGetStatusFiles(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGitCommandStashDo(t *testing.T) {
|
||||
gitCmd := newDummyGitCommand()
|
||||
gitCmd.OSCommand.command = func(cmd string, args ...string) *exec.Cmd {
|
||||
assert.EqualValues(t, "git", cmd)
|
||||
assert.EqualValues(t, []string{"stash", "drop", "stash@{1}"}, args)
|
||||
|
||||
return exec.Command("echo")
|
||||
}
|
||||
|
||||
assert.NoError(t, gitCmd.StashDo(1, "drop"))
|
||||
}
|
||||
|
||||
func TestGitCommandDiff(t *testing.T) {
|
||||
gitCommand := newDummyGitCommand()
|
||||
assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh"))
|
||||
|
Reference in New Issue
Block a user