1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-03 00:57:52 +02:00

Introduce failing "UnsetUpstream" test

This commit is contained in:
Luka Markušić
2023-11-04 23:19:38 +01:00
parent bb705d91a4
commit e0fc8fe25b

View File

@ -6,21 +6,27 @@ import (
) )
var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{ var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Reset the upstream of a branch", Description: "Unset upstream of selected branch, both when it exists and when it doesn't",
ExtraCmdArgs: []string{}, ExtraCmdArgs: []string{},
Skip: false, Skip: false,
SetupConfig: func(config *config.AppConfig) {}, SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one") shell.
shell.CloneIntoRemote("origin") EmptyCommit("one").
shell.SetBranchUpstream("master", "origin/master") NewBranch("branch_to_remove").
Checkout("master").
CloneIntoRemote("origin").
SetBranchUpstream("master", "origin/master").
SetBranchUpstream("branch_to_remove", "origin/branch_to_remove").
// to get the "(upstream gone)" branch status
RunCommand([]string{"git", "push", "origin", "--delete", "branch_to_remove"})
}, },
Run: func(t *TestDriver, keys config.KeybindingConfig) { Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Branches(). t.Views().Branches().
Focus(). Focus().
Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream Press(keys.Universal.NextScreenMode). // we need to enlargen the window to see the upstream
Lines( SelectedLines(
Contains("master").Contains("origin master").IsSelected(), Contains("master").Contains("origin master"),
). ).
Press(keys.Branches.SetUpstream). Press(keys.Branches.SetUpstream).
Tap(func() { Tap(func() {
@ -29,8 +35,29 @@ var UnsetUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Select(Contains("Unset upstream of selected branch")). Select(Contains("Unset upstream of selected branch")).
Confirm() Confirm()
}). }).
Lines( SelectedLines(
Contains("master").DoesNotContain("origin master").IsSelected(), Contains("master").DoesNotContain("origin master"),
)
t.Views().Branches().
Focus().
SelectNextItem().
SelectedLines(
Contains("branch_to_remove").Contains("origin branch_to_remove").Contains("upstream gone"),
).
Press(keys.Branches.SetUpstream).
Tap(func() {
t.ExpectPopup().Menu().
Title(Equals("Upstream options")).
Select(Contains("Unset upstream of selected branch")).
Confirm()
t.ExpectPopup().Alert().
Title(Equals("Error")).
Content(Equals("The selected branch has no upstream (or the upstream is not stored locally)")).
Cancel()
}).
SelectedLines(
Contains("branch_to_remove").Contains("origin branch_to_remove").Contains("upstream gone"),
) )
}, },
}) })