Skip to content

Commit

Permalink
migrate test for rename branch and pull
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Dec 30, 2022
1 parent 277ca70 commit 6f70945
Show file tree
Hide file tree
Showing 52 changed files with 64 additions and 111 deletions.
6 changes: 6 additions & 0 deletions pkg/integration/components/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,9 @@ func (self *Shell) RemoveRemoteBranch(remoteName string, branch string) *Shell {

return self
}

func (self *Shell) HardReset(ref string) *Shell {
self.RunCommand(fmt.Sprintf("git reset --hard %s", ref))

return self
}
57 changes: 57 additions & 0 deletions pkg/integration/tests/sync/rename_branch_and_pull.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package sync

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var RenameBranchAndPull = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Rename a branch to no longer match its upstream, then pull from the upstream",
ExtraCmdArgs: "",
Skip: false,
SetupConfig: func(config *config.AppConfig) {
config.UserConfig.Git.AutoFetch = false
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")

shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")

// remove the 'two' commit so that we have something to pull from the remote
shell.HardReset("HEAD^")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Lines(
Contains("one"),
)

t.Views().Branches().
Focus().
Lines(
Contains("master"),
).
Press(keys.Branches.RenameBranch).
Tap(func() {
t.ExpectPopup().Confirmation().
Title(Equals("rename branch")).
Content(Equals("This branch is tracking a remote. This action will only rename the local branch name, not the name of the remote branch. Continue?")).
Confirm()

t.ExpectPopup().Prompt().
Title(Contains("Enter new branch name")).
InitialText(Equals("master")).
Type("-local").
Confirm()
}).
Press(keys.Universal.PullFiles)

t.Views().Commits().
Lines(
Contains("two"),
Contains("one"),
)
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var tests = []*components.IntegrationTest{
diff.DiffAndApplyPatch,
diff.DiffCommits,
sync.FetchPrune,
sync.RenameBranchAndPull,
}

func GetTests() []*components.IntegrationTest {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions test/integration/fetchRemoteBranchWithNonmatchingName/setup.sh

This file was deleted.

This file was deleted.

0 comments on commit 6f70945

Please sign in to comment.