Skip to content

Commit 94fc4d7

Browse files
committed
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.
1 parent 682e542 commit 94fc4d7

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

pkg/commands/git_commands/commit_loader_test.go

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,15 @@ func TestGetCommits(t *testing.T) {
3333
expectedCommits []*models.Commit
3434
expectedError error
3535
logOrder string
36-
rebaseMode enums.RebaseMode
3736
opts GetCommitsOptions
3837
mainBranches []string
3938
}
4039

4140
scenarios := []scenario{
4241
{
43-
testName: "should return no commits if there are none",
44-
logOrder: "topo-order",
45-
rebaseMode: enums.REBASE_MODE_NONE,
46-
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
42+
testName: "should return no commits if there are none",
43+
logOrder: "topo-order",
44+
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
4745
runner: oscommands.NewFakeRunner(t).
4846
ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
4947
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) {
5250
expectedError: nil,
5351
},
5452
{
55-
testName: "should use proper upstream name for branch",
56-
logOrder: "topo-order",
57-
rebaseMode: enums.REBASE_MODE_NONE,
58-
opts: GetCommitsOptions{RefName: "refs/heads/mybranch", RefForPushedStatus: "refs/heads/mybranch", IncludeRebaseCommits: false},
53+
testName: "should use proper upstream name for branch",
54+
logOrder: "topo-order",
55+
opts: GetCommitsOptions{RefName: "refs/heads/mybranch", RefForPushedStatus: "refs/heads/mybranch", IncludeRebaseCommits: false},
5956
runner: oscommands.NewFakeRunner(t).
6057
ExpectGitArgs([]string{"merge-base", "refs/heads/mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
6158
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) {
6663
{
6764
testName: "should return commits if they are present",
6865
logOrder: "topo-order",
69-
rebaseMode: enums.REBASE_MODE_NONE,
7066
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
7167
mainBranches: []string{"master", "main", "develop"},
7268
runner: oscommands.NewFakeRunner(t).
@@ -203,7 +199,6 @@ func TestGetCommits(t *testing.T) {
203199
{
204200
testName: "should not call merge-base for mainBranches if none exist",
205201
logOrder: "topo-order",
206-
rebaseMode: enums.REBASE_MODE_NONE,
207202
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
208203
mainBranches: []string{"master", "main"},
209204
runner: oscommands.NewFakeRunner(t).
@@ -240,7 +235,6 @@ func TestGetCommits(t *testing.T) {
240235
{
241236
testName: "should call merge-base for all main branches that exist",
242237
logOrder: "topo-order",
243-
rebaseMode: enums.REBASE_MODE_NONE,
244238
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
245239
mainBranches: []string{"master", "main", "develop", "1.0-hotfixes"},
246240
runner: oscommands.NewFakeRunner(t).
@@ -277,10 +271,9 @@ func TestGetCommits(t *testing.T) {
277271
expectedError: nil,
278272
},
279273
{
280-
testName: "should not specify order if `log.order` is `default`",
281-
logOrder: "default",
282-
rebaseMode: enums.REBASE_MODE_NONE,
283-
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
274+
testName: "should not specify order if `log.order` is `default`",
275+
logOrder: "default",
276+
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", IncludeRebaseCommits: false},
284277
runner: oscommands.NewFakeRunner(t).
285278
ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
286279
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) {
289282
expectedError: nil,
290283
},
291284
{
292-
testName: "should set filter path",
293-
logOrder: "default",
294-
rebaseMode: enums.REBASE_MODE_NONE,
295-
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", FilterPath: "src"},
285+
testName: "should set filter path",
286+
logOrder: "default",
287+
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: "mybranch", FilterPath: "src"},
296288
runner: oscommands.NewFakeRunner(t).
297289
ExpectGitArgs([]string{"merge-base", "mybranch", "mybranch@{u}"}, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
298290
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) {
312304
builder := &CommitLoader{
313305
Common: common,
314306
cmd: cmd,
315-
getRebaseMode: func() (enums.RebaseMode, error) { return scenario.rebaseMode, nil },
307+
getRebaseMode: func() (enums.RebaseMode, error) { return enums.REBASE_MODE_NONE, nil },
316308
dotGitDir: ".git",
317309
readFile: func(filename string) ([]byte, error) {
318310
return []byte(""), nil

0 commit comments

Comments
 (0)