1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

work towards more interactive rebase options

This commit is contained in:
Jesse Duffield
2019-02-19 23:36:29 +11:00
parent 935f774834
commit 0228e25084
9 changed files with 263 additions and 201 deletions

View File

@ -1152,70 +1152,6 @@ func TestGitCommandSquashPreviousTwoCommits(t *testing.T) {
}
}
// TestGitCommandSquashFixupCommit is a function.
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("test")
}
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"))
})
}
}
// TestGitCommandCatFile is a function.
func TestGitCommandCatFile(t *testing.T) {
gitCmd := newDummyGitCommand()