From 94fc4d7eb4d60c9a67096190f80620a058fe5f53 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 10 Jun 2024 16:22:50 +0200 Subject: [PATCH] Remove rebaseMode field from TestGetCommits scenario All test cases set it to enums.REBASE_MODE_NONE, so we can simplify things a little bit by hard-coding that. This makes the changes in the following commits a little easier. --- .../git_commands/commit_loader_test.go | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go index f9c4cdff6..a6b4e58ae 100644 --- a/pkg/commands/git_commands/commit_loader_test.go +++ b/pkg/commands/git_commands/commit_loader_test.go @@ -33,17 +33,15 @@ func TestGetCommits(t *testing.T) { expectedCommits []*models.Commit expectedError error logOrder string - rebaseMode enums.RebaseMode opts GetCommitsOptions mainBranches []string } scenarios := []scenario{ { - testName: "should return no commits if there are none", - logOrder: "topo-order", - rebaseMode: enums.REBASE_MODE_NONE, - opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, + testName: "should return no commits if there are none", + logOrder: "topo-order", + opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, runner: oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil). ExpectGitArgs([]string{"log", "HEAD", "--topo-order", "--oneline", "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s", "--abbrev=40", "--no-show-signature", "--"}, "", nil), @@ -52,10 +50,9 @@ func TestGetCommits(t *testing.T) { expectedError: nil, }, { - testName: "should use proper upstream name for branch", - logOrder: "topo-order", - rebaseMode: enums.REBASE_MODE_NONE, - opts: GetCommitsOptions{RefName: "refs/heads/mybranch", RefForPushedStatus: "refs/heads/mybranch", IncludeRebaseCommits: false}, + testName: "should use proper upstream name for branch", + logOrder: "topo-order", + opts: GetCommitsOptions{RefName: "refs/heads/mybranch", RefForPushedStatus: "refs/heads/mybranch", IncludeRebaseCommits: false}, runner: oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"merge-base", "refs/heads/mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil). ExpectGitArgs([]string{"log", "refs/heads/mybranch", "--topo-order", "--oneline", "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s", "--abbrev=40", "--no-show-signature", "--"}, "", nil), @@ -66,7 +63,6 @@ func TestGetCommits(t *testing.T) { { testName: "should return commits if they are present", logOrder: "topo-order", - rebaseMode: enums.REBASE_MODE_NONE, opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, mainBranches: []string{"master", "main", "develop"}, runner: oscommands.NewFakeRunner(t). @@ -203,7 +199,6 @@ func TestGetCommits(t *testing.T) { { testName: "should not call merge-base for mainBranches if none exist", logOrder: "topo-order", - rebaseMode: enums.REBASE_MODE_NONE, opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, mainBranches: []string{"master", "main"}, runner: oscommands.NewFakeRunner(t). @@ -240,7 +235,6 @@ func TestGetCommits(t *testing.T) { { testName: "should call merge-base for all main branches that exist", logOrder: "topo-order", - rebaseMode: enums.REBASE_MODE_NONE, opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, mainBranches: []string{"master", "main", "develop", "1.0-hotfixes"}, runner: oscommands.NewFakeRunner(t). @@ -277,10 +271,9 @@ func TestGetCommits(t *testing.T) { expectedError: nil, }, { - testName: "should not specify order if `log.order` is `default`", - logOrder: "default", - rebaseMode: enums.REBASE_MODE_NONE, - opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, + testName: "should not specify order if `log.order` is `default`", + logOrder: "default", + opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false}, runner: oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil). ExpectGitArgs([]string{"log", "HEAD", "--oneline", "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s", "--abbrev=40", "--no-show-signature", "--"}, "", nil), @@ -289,10 +282,9 @@ func TestGetCommits(t *testing.T) { expectedError: nil, }, { - testName: "should set filter path", - logOrder: "default", - rebaseMode: enums.REBASE_MODE_NONE, - opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", FilterPath: "src"}, + testName: "should set filter path", + logOrder: "default", + opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", FilterPath: "src"}, runner: oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil). ExpectGitArgs([]string{"log", "HEAD", "--oneline", "--pretty=format:%H%x00%at%x00%aN%x00%ae%x00%D%x00%p%x00%m%x00%s", "--abbrev=40", "--follow", "--no-show-signature", "--", "src"}, "", nil), @@ -312,7 +304,7 @@ func TestGetCommits(t *testing.T) { builder := &CommitLoader{ Common: common, cmd: cmd, - getRebaseMode: func() (enums.RebaseMode, error) { return scenario.rebaseMode, nil }, + getRebaseMode: func() (enums.RebaseMode, error) { return enums.REBASE_MODE_NONE, nil }, dotGitDir: ".git", readFile: func(filename string) ([]byte, error) { return []byte(""), nil