summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git_commands/branch_test.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-20 16:55:07 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-05-20 16:55:15 +1000
commit63ddc52a6b0b69b656b106ee5ae74dd736ac6317 (patch)
treeb5b67588b7ba45c056b345562f9cf1ba0371eb01 /pkg/commands/git_commands/branch_test.go
parentb07c4fc0019e6432d981127019c938dcefcf808a (diff)
Increase test coverage
Diffstat (limited to 'pkg/commands/git_commands/branch_test.go')
-rw-r--r--pkg/commands/git_commands/branch_test.go52
1 files changed, 47 insertions, 5 deletions
diff --git a/pkg/commands/git_commands/branch_test.go b/pkg/commands/git_commands/branch_test.go
index 2fdf7d9c2..75c288203 100644
--- a/pkg/commands/git_commands/branch_test.go
+++ b/pkg/commands/git_commands/branch_test.go
@@ -5,6 +5,7 @@ import (
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+ "github.com/jesseduffield/lazygit/pkg/config"
"github.com/stretchr/testify/assert"
)
@@ -99,12 +100,53 @@ func TestBranchDeleteBranch(t *testing.T) {
}
func TestBranchMerge(t *testing.T) {
- runner := oscommands.NewFakeRunner(t).
- Expect(`git merge --no-edit "test"`, "", nil)
- instance := buildBranchCommands(commonDeps{runner: runner})
+ scenarios := []struct {
+ testName string
+ userConfig *config.UserConfig
+ opts MergeOpts
+ branchName string
+ expected string
+ }{
+ {
+ testName: "basic",
+ userConfig: &config.UserConfig{},
+ opts: MergeOpts{},
+ branchName: "mybranch",
+ expected: `git merge --no-edit "mybranch"`,
+ },
+ {
+ testName: "merging args",
+ userConfig: &config.UserConfig{
+ Git: config.GitConfig{
+ Merging: config.MergingConfig{
+ Args: "--merging-args", // it's up to the user what they put here
+ },
+ },
+ },
+ opts: MergeOpts{},
+ branchName: "mybranch",
+ expected: `git merge --no-edit --merging-args "mybranch"`,
+ },
+ {
+ testName: "fast forward only",
+ userConfig: &config.UserConfig{},
+ opts: MergeOpts{FastForwardOnly: true},
+ branchName: "mybranch",
+ expected: `git merge --no-edit --ff-only "mybranch"`,
+ },
+ }
- assert.NoError(t, instance.Merge("test", MergeOpts{}))
- runner.CheckForMissingCalls()
+ for _, s := range scenarios {
+ s := s
+ t.Run(s.testName, func(t *testing.T) {
+ runner := oscommands.NewFakeRunner(t).
+ Expect(s.expected, "", nil)
+ instance := buildBranchCommands(commonDeps{runner: runner, userConfig: s.userConfig})
+
+ assert.NoError(t, instance.Merge(s.branchName, s.opts))
+ runner.CheckForMissingCalls()
+ })
+ }
}
func TestBranchCheckout(t *testing.T) {