Skip to content

Commit 2e47902

Browse files
Chris McDonnellstefanhaller
Chris McDonnell
authored andcommitted
Add integration test for resetting to upstream branch with duplicate name
1 parent ab17982 commit 2e47902

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package branch
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var ResetToDuplicateNamedUpstream = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Hard reset the current branch to an upstream branch when there is a competing tag name",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.
15+
CloneIntoRemote("origin").
16+
NewBranch("foo").
17+
EmptyCommit("commit 1").
18+
PushBranchAndSetUpstream("origin", "foo").
19+
EmptyCommit("commit 2").
20+
CreateLightweightTag("origin/foo", "HEAD")
21+
},
22+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
23+
t.Views().Commits().Lines(
24+
Contains("commit 2"),
25+
Contains("commit 1"),
26+
)
27+
t.Views().Tags().Focus().Lines(Contains("origin/foo"))
28+
29+
t.Views().Remotes().Focus().
30+
Lines(Contains("origin")).
31+
PressEnter()
32+
t.Views().RemoteBranches().IsFocused().
33+
Lines(Contains("foo")).
34+
Press(keys.Commits.ViewResetOptions)
35+
t.ExpectPopup().Menu().
36+
Title(Contains("Reset to origin/foo")).
37+
Select(Contains("Hard reset")).
38+
Confirm()
39+
40+
t.Views().Commits().Lines(
41+
Contains("commit 1"),
42+
)
43+
44+
t.Views().Tags().Focus().
45+
Lines(Contains("origin/foo")).
46+
Press(keys.Commits.ViewResetOptions)
47+
t.ExpectPopup().Menu().
48+
Title(Contains("Reset to origin/foo")).
49+
Select(Contains("Hard reset")).
50+
Confirm()
51+
52+
t.Views().Commits().Lines(
53+
Contains("commit 2"),
54+
Contains("commit 1"),
55+
)
56+
},
57+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ var tests = []*components.IntegrationTest{
7272
branch.Rename,
7373
branch.Reset,
7474
branch.ResetToDuplicateNamedTag,
75+
branch.ResetToDuplicateNamedUpstream,
7576
branch.ResetToUpstream,
7677
branch.SelectCommitsOfCurrentBranch,
7778
branch.SetUpstream,

0 commit comments

Comments
 (0)