summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/worktree
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-28 18:27:14 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:24 +1000
commit4c5b1574f147fe2005bcd30bbb5dc106c4838b92 (patch)
treece7fada27e54f793024e740add3e5779a2c63262 /pkg/integration/tests/worktree
parentde57cfd6ff17751f7243476441beab6486fb4381 (diff)
Centralise logic for obtaining repo paths
There are quite a few paths you might want to get e.g. the repo's path, the worktree's path, the repo's git dir path, the worktree's git dir path. I want these all obtained once and then used when needed rather than having to have IO whenever we need them. This is not so much about reducing time spent on IO as it is about not having to care about errors every time we want a path.
Diffstat (limited to 'pkg/integration/tests/worktree')
-rw-r--r--pkg/integration/tests/worktree/associate_branch_bisect.go (renamed from pkg/integration/tests/worktree/bisect.go)2
-rw-r--r--pkg/integration/tests/worktree/associate_branch_rebase.go (renamed from pkg/integration/tests/worktree/rebase.go)2
-rw-r--r--pkg/integration/tests/worktree/bare_repo.go43
3 files changed, 44 insertions, 3 deletions
diff --git a/pkg/integration/tests/worktree/bisect.go b/pkg/integration/tests/worktree/associate_branch_bisect.go
index 143f8114f..77d46e176 100644
--- a/pkg/integration/tests/worktree/bisect.go
+++ b/pkg/integration/tests/worktree/associate_branch_bisect.go
@@ -12,7 +12,7 @@ import (
// not bothering to test the linked worktree here because it's the same logic as the rebase test
-var Bisect = NewIntegrationTest(NewIntegrationTestArgs{
+var AssociateBranchBisect = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Verify that when you start a bisect in a linked worktree, Lazygit still associates the worktree with the branch",
ExtraCmdArgs: []string{},
Skip: false,
diff --git a/pkg/integration/tests/worktree/rebase.go b/pkg/integration/tests/worktree/associate_branch_rebase.go
index 8b91702b5..b0b04b805 100644
--- a/pkg/integration/tests/worktree/rebase.go
+++ b/pkg/integration/tests/worktree/associate_branch_rebase.go
@@ -13,7 +13,7 @@ import (
// We need different logic for associated the branch depending on whether it's a main worktree or
// linked worktree, so this test handles both.
-var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
+var AssociateBranchRebase = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Verify that when you start a rebase in a linked or main worktree, Lazygit still associates the worktree with the branch",
ExtraCmdArgs: []string{},
Skip: false,
diff --git a/pkg/integration/tests/worktree/bare_repo.go b/pkg/integration/tests/worktree/bare_repo.go
index af0133227..2343b112e 100644
--- a/pkg/integration/tests/worktree/bare_repo.go
+++ b/pkg/integration/tests/worktree/bare_repo.go
@@ -6,7 +6,7 @@ import (
)
var BareRepo = NewIntegrationTest(NewIntegrationTestArgs{
- Description: "Open lazygit in the worktree of a bare repo",
+ Description: "Open lazygit in the worktree of a bare repo and do a rebase/bisect",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
@@ -23,6 +23,8 @@ var BareRepo = NewIntegrationTest(NewIntegrationTestArgs{
shell.NewBranch("mybranch")
shell.CreateFileAndAdd("blah", "blah")
shell.Commit("initial commit")
+ shell.EmptyCommit("commit two")
+ shell.EmptyCommit("commit three")
shell.RunCommand([]string{"git", "clone", "--bare", ".", "../.bare"})
@@ -45,6 +47,45 @@ var BareRepo = NewIntegrationTest(NewIntegrationTestArgs{
Contains("worktree2 (worktree)"),
)
+ // test that a rebase works fine
+ // (rebase uses the git dir of the worktree so we're confirming that it points
+ // to the right git dir)
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit three").IsSelected(),
+ Contains("commit two"),
+ Contains("initial commit"),
+ ).
+ Press(keys.Commits.MoveDownCommit).
+ Lines(
+ Contains("commit two"),
+ Contains("commit three").IsSelected(),
+ Contains("initial commit"),
+ ).
+ // test that bisect works fine (same logic as above)
+ NavigateToLine(Contains("commit two")).
+ Press(keys.Commits.ViewBisectOptions).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Bisect")).
+ Select(MatchesRegexp(`Mark .* as bad`)).
+ Confirm()
+
+ t.Views().Information().Content(Contains("Bisecting"))
+ }).
+ NavigateToLine(Contains("initial commit")).
+ Press(keys.Commits.ViewBisectOptions).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Bisect")).
+ Select(MatchesRegexp(`Mark .* as good`)).
+ Confirm()
+
+ t.Views().Information().Content(Contains("Bisecting"))
+ })
+
+ // switch to other worktree
t.Views().Worktrees().
Focus().
Lines(