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

cleanup integration test code

This commit is contained in:
Jesse Duffield
2023-02-26 11:49:15 +11:00
parent 8b5d59c238
commit f7e8b2dd71
70 changed files with 322 additions and 272 deletions

View File

@@ -32,14 +32,14 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Commits().
Focus().
SelectedLine(Contains("commit 10")).
NavigateToListItem(Contains("commit 09")).
NavigateToLine(Contains("commit 09")).
Tap(func() {
markCommitAsBad()
t.Views().Information().Content(Contains("bisecting"))
}).
SelectedLine(Contains("<-- bad")).
NavigateToListItem(Contains("commit 02")).
NavigateToLine(Contains("commit 02")).
Tap(markCommitAsGood).
// lazygit will land us in the commit between our good and bad commits.
SelectedLine(Contains("commit 05").Contains("<-- current")).

View File

@@ -35,7 +35,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Content(Contains("Are you sure you want to rebase 'first-change-branch' on top of 'second-change-branch'?")).
Confirm()
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@@ -48,7 +48,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("rebasing"))
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Information().Content(DoesNotContain("rebasing"))

View File

@@ -43,7 +43,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("rebasing"))
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().IsFocused().
SelectedLine(MatchesRegexp("UU.*file"))
@@ -75,7 +75,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
IsFocused().
PressPrimaryAction()
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Information().Content(DoesNotContain("rebasing"))

View File

@@ -52,7 +52,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
Confirm()
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@@ -65,7 +65,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
SelectNextItem().
PressPrimaryAction()
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Files().IsEmpty()

View File

@@ -25,7 +25,7 @@ var ResolveExternally = NewIntegrationTest(NewIntegrationTestArgs{
}).
Press(keys.Universal.Refresh)
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Files().
IsEmpty()

View File

@@ -49,6 +49,6 @@ var ResolveMultipleFiles = NewIntegrationTest(NewIntegrationTestArgs{
).
PressPrimaryAction()
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
},
})

View File

@@ -99,7 +99,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "DU", label: "deleted-us.txt", menuTitle: "deleted-us.txt"},
})
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
discardOneByOne([]statusFile{
{status: "MD", label: "change-delete.txt", menuTitle: "change-delete.txt"},

View File

@@ -37,40 +37,3 @@ var SelectFile = NewIntegrationTest(NewIntegrationTestArgs{
postFilterTest(t)
},
})
func commonSetup(shell *Shell) {
shell.CreateFileAndAdd("filterFile", "original filterFile content")
shell.CreateFileAndAdd("otherFile", "original otherFile content")
shell.Commit("both files")
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
shell.Commit("only otherFile")
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
shell.Commit("only filterFile")
}
func postFilterTest(t *TestDriver) {
t.Views().Information().Content(Contains("filtering by 'filterFile'"))
t.Views().Commits().
IsFocused().
Lines(
Contains(`only filterFile`).IsSelected(),
Contains(`both files`),
).
SelectNextItem().
PressEnter()
// we only show the filtered file's changes in the main view
t.Views().Main().
Content(Contains("filterFile").DoesNotContain("otherFile"))
// when you click into the commit itself, you see all files from that commit
t.Views().CommitFiles().
IsFocused().
Lines(
Contains(`filterFile`),
Contains(`otherFile`),
)
}

View File

@@ -0,0 +1,42 @@
package filter_by_path
import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func commonSetup(shell *Shell) {
shell.CreateFileAndAdd("filterFile", "original filterFile content")
shell.CreateFileAndAdd("otherFile", "original otherFile content")
shell.Commit("both files")
shell.UpdateFileAndAdd("otherFile", "new otherFile content")
shell.Commit("only otherFile")
shell.UpdateFileAndAdd("filterFile", "new filterFile content")
shell.Commit("only filterFile")
}
func postFilterTest(t *TestDriver) {
t.Views().Information().Content(Contains("filtering by 'filterFile'"))
t.Views().Commits().
IsFocused().
Lines(
Contains(`only filterFile`).IsSelected(),
Contains(`both files`),
).
SelectNextItem().
PressEnter()
// we only show the filtered file's changes in the main view
t.Views().Main().
Content(Contains("filterFile").DoesNotContain("otherFile"))
// when you click into the commit itself, you see all files from that commit
t.Views().CommitFiles().
IsFocused().
Lines(
Contains(`filterFile`),
Contains(`otherFile`),
)
}

View File

@@ -22,7 +22,7 @@ var AmendFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.AmendToCommit).
Tap(func() {
t.ExpectPopup().Confirmation().

View File

@@ -21,14 +21,14 @@ var EditFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Universal.Edit).
Lines(
Contains("commit 02"),
MatchesRegexp("YOU ARE HERE.*commit 01").IsSelected(),
).
Tap(func() {
t.Actions().ContinueRebase()
t.Common().ContinueRebase()
}).
Lines(
Contains("commit 02"),

View File

@@ -21,7 +21,7 @@ var FixupFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.MarkCommitAsFixup).
Tap(func() {
t.ExpectPopup().Alert().

View File

@@ -22,7 +22,7 @@ var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 02")).
NavigateToLine(Contains("commit 02")).
Press(keys.Commits.MarkCommitAsFixup).
Tap(func() {
t.ExpectPopup().Confirmation().

View File

@@ -22,7 +22,7 @@ var MoveInRebase = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Universal.Edit).
Lines(
Contains("commit 04"),
@@ -84,7 +84,7 @@ var MoveInRebase = NewIntegrationTest(NewIntegrationTestArgs{
Contains("YOU ARE HERE").Contains("commit 01"),
).
Tap(func() {
t.Actions().ContinueRebase()
t.Common().ContinueRebase()
}).
Lines(
Contains("commit 04"),

View File

@@ -31,7 +31,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Contains("first commit to edit"),
Contains("initial commit"),
).
NavigateToListItem(Contains("first commit to edit")).
NavigateToLine(Contains("first commit to edit")).
Press(keys.Universal.Edit).
Lines(
MatchesRegexp("pick.*commit to fixup"),
@@ -82,7 +82,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Contains("initial commit"),
).
Tap(func() {
t.Actions().ContinueRebase()
t.Common().ContinueRebase()
}).
Lines(
MatchesRegexp("fixup.*commit to fixup").IsSelected(),
@@ -92,7 +92,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
Contains("initial commit"),
).
Tap(func() {
t.Actions().ContinueRebase()
t.Common().ContinueRebase()
}).
Lines(
Contains("second commit to edit").IsSelected(),

View File

@@ -24,7 +24,7 @@ var RewordFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.RenameCommit).
Tap(func() {
t.ExpectPopup().Prompt().

View File

@@ -0,0 +1,68 @@
package interactive_rebase
import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func handleConflictsFromSwap(t *TestDriver) {
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU myfile"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("one"),
Contains("======="),
Contains("three"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // pick "three"
t.Common().ContinueOnConflictsResolved()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU myfile"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("three"),
Contains("======="),
Contains("two"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // pick "two"
t.Common().ContinueOnConflictsResolved()
t.Views().Commits().
Focus().
Lines(
Contains("commit two").IsSelected(),
Contains("commit three"),
Contains("commit one"),
).
Tap(func() {
t.Views().Main().Content(Contains("-three").Contains("+two"))
}).
SelectNextItem().
Tap(func() {
t.Views().Main().Content(Contains("-one").Contains("+three"))
})
}

View File

@@ -21,7 +21,7 @@ var SquashDownFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.SquashDown).
Tap(func() {
t.ExpectPopup().Alert().

View File

@@ -22,7 +22,7 @@ var SquashDownSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 02")).
NavigateToLine(Contains("commit 02")).
Press(keys.Commits.SquashDown).
Tap(func() {
t.ExpectPopup().Confirmation().

View File

@@ -22,7 +22,7 @@ var SquashFixupsAboveFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit 02"),
Contains("commit 01"),
).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.CreateFixupCommit).
Tap(func() {
t.ExpectPopup().Confirmation().
@@ -30,7 +30,7 @@ var SquashFixupsAboveFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
Content(Contains("Are you sure you want to create a fixup! commit for commit")).
Confirm()
}).
NavigateToListItem(Contains("commit 01")).
NavigateToLine(Contains("commit 01")).
Press(keys.Commits.SquashAboveCommits).
Tap(func() {
t.ExpectPopup().Confirmation().

View File

@@ -26,7 +26,7 @@ var SwapInRebaseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
Contains("commit two"),
Contains("commit one"),
).
NavigateToListItem(Contains("commit one")).
NavigateToLine(Contains("commit one")).
Press(keys.Universal.Edit).
Lines(
Contains("commit three"),
@@ -41,72 +41,9 @@ var SwapInRebaseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
Contains("YOU ARE HERE").Contains("commit one"),
).
Tap(func() {
t.Actions().ContinueRebase()
t.Common().ContinueRebase()
})
handleConflictsFromSwap(t)
},
})
func handleConflictsFromSwap(t *TestDriver) {
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU myfile"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("one"),
Contains("======="),
Contains("three"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // pick "three"
t.Actions().ContinueOnConflictsResolved()
t.Actions().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
Lines(
Contains("UU myfile"),
).
PressEnter()
t.Views().MergeConflicts().
IsFocused().
TopLines(
Contains("<<<<<<< HEAD"),
Contains("three"),
Contains("======="),
Contains("two"),
Contains(">>>>>>>"),
).
SelectNextItem().
PressPrimaryAction() // pick "two"
t.Actions().ContinueOnConflictsResolved()
t.Views().Commits().
Focus().
Lines(
Contains("commit two").IsSelected(),
Contains("commit three"),
Contains("commit one"),
).
Tap(func() {
t.Views().Main().Content(Contains("-three").Contains("+two"))
}).
SelectNextItem().
Tap(func() {
t.Views().Main().Content(Contains("-one").Contains("+three"))
})
}

View File

@@ -50,7 +50,7 @@ var Apply = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().PatchBuildingSecondary().Content(Contains("second line"))
t.Actions().SelectPatchOption(MatchesRegexp(`apply patch$`))
t.Common().SelectPatchOption(MatchesRegexp(`apply patch$`))
t.Views().Files().
Focus().

View File

@@ -35,7 +35,7 @@ var ApplyInReverse = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
t.Actions().SelectPatchOption(Contains("apply patch in reverse"))
t.Common().SelectPatchOption(Contains("apply patch in reverse"))
t.Views().Files().
Focus().

View File

@@ -40,7 +40,7 @@ var CopyPatchToClipboard = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("building patch"))
t.Actions().SelectPatchOption(Contains("copy patch to clipboard"))
t.Common().SelectPatchOption(Contains("copy patch to clipboard"))
t.ExpectToast(Contains("Patch copied to clipboard"))

View File

@@ -35,7 +35,7 @@ var MoveToIndex = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
t.Actions().SelectPatchOption(Contains("move patch out into index"))
t.Common().SelectPatchOption(Contains("move patch out into index"))
t.Views().Files().
Lines(

View File

@@ -28,7 +28,7 @@ var MoveToIndexPartial = NewIntegrationTest(NewIntegrationTestArgs{
Contains("second commit"),
Contains("first commit"),
).
NavigateToListItem(Contains("second commit")).
NavigateToLine(Contains("second commit")).
PressEnter()
t.Views().CommitFiles().
@@ -61,7 +61,7 @@ var MoveToIndexPartial = NewIntegrationTest(NewIntegrationTestArgs{
Contains(` third line`),
)
t.Actions().SelectPatchOption(Contains("move patch out into index"))
t.Common().SelectPatchOption(Contains("move patch out into index"))
t.Views().Files().
Lines(

View File

@@ -40,9 +40,9 @@ var MoveToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("building patch"))
t.Actions().SelectPatchOption(Contains("move patch out into index"))
t.Common().SelectPatchOption(Contains("move patch out into index"))
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@@ -62,7 +62,7 @@ var MoveToIndexWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
).
PressPrimaryAction()
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.ExpectPopup().Alert().
Title(Equals("Error")).

View File

@@ -40,7 +40,7 @@ var MoveToNewCommit = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Information().Content(Contains("building patch"))
t.Actions().SelectPatchOption(Contains("move patch into new commit"))
t.Common().SelectPatchOption(Contains("move patch into new commit"))
t.Views().CommitFiles().
IsFocused().

View File

@@ -35,7 +35,7 @@ var RemoveFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().PatchBuildingSecondary().Content(Contains("+file1 content"))
t.Actions().SelectPatchOption(Contains("remove patch from original commit"))
t.Common().SelectPatchOption(Contains("remove patch from original commit"))
t.Views().Files().IsEmpty()

View File

@@ -43,7 +43,7 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Secondary().Content(Contains("direct file content"))
}).
NavigateToListItem(Contains("hunk-file")).
NavigateToLine(Contains("hunk-file")).
PressEnter()
t.Views().PatchBuilding().
@@ -92,7 +92,7 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().CommitFiles().
IsFocused().
NavigateToListItem(Contains("line-file")).
NavigateToLine(Contains("line-file")).
PressEnter()
t.Views().PatchBuilding().
@@ -106,11 +106,11 @@ var SpecificSelection = NewIntegrationTest(NewIntegrationTestArgs{
Contains("+2a"),
).
PressPrimaryAction().
NavigateToListItem(Contains("+2c")).
NavigateToLine(Contains("+2c")).
Press(keys.Main.ToggleDragSelect).
NavigateToListItem(Contains("+2e")).
NavigateToLine(Contains("+2e")).
PressPrimaryAction().
NavigateToListItem(Contains("+2g")).
NavigateToLine(Contains("+2g")).
PressPrimaryAction().
Tap(func() {
t.Views().Information().Content(Contains("building patch"))

View File

@@ -41,7 +41,7 @@ var StartNewPatch = NewIntegrationTest(NewIntegrationTestArgs{
t.Views().Commits().
IsFocused().
NavigateToListItem(Contains("first commit")).
NavigateToLine(Contains("first commit")).
PressEnter()
t.Views().CommitFiles().

View File

@@ -33,13 +33,13 @@ var DiscardAllChanges = NewIntegrationTest(NewIntegrationTestArgs{
// discard the line
Press(keys.Universal.Remove).
Tap(func() {
t.Actions().ConfirmDiscardLines()
t.Common().ConfirmDiscardLines()
}).
SelectedLines(Contains("+four")).
// discard the other line
Press(keys.Universal.Remove).
Tap(func() {
t.Actions().ConfirmDiscardLines()
t.Common().ConfirmDiscardLines()
// because there are no more changes in file1 we switch to file2
t.Views().Files().

View File

@@ -139,7 +139,7 @@ var StageHunks = NewIntegrationTest(NewIntegrationTestArgs{
).
Press(keys.Universal.Remove).
Tap(func() {
t.Actions().ConfirmDiscardLines()
t.Common().ConfirmDiscardLines()
}).
Content(DoesNotContain("-3a").DoesNotContain("+3b")).
SelectedLines(

View File

@@ -30,7 +30,7 @@ var StageRanges = NewIntegrationTest(NewIntegrationTestArgs{
Contains("+three"),
).
Press(keys.Main.ToggleDragSelect).
NavigateToListItem(Contains("+five")).
NavigateToLine(Contains("+five")).
SelectedLines(
Contains("+three"),
Contains("+four"),
@@ -61,7 +61,7 @@ var StageRanges = NewIntegrationTest(NewIntegrationTestArgs{
Contains("+three"),
).
Press(keys.Main.ToggleDragSelect).
NavigateToListItem(Contains("+five")).
NavigateToLine(Contains("+five")).
SelectedLines(
Contains("+three"),
Contains("+four"),
@@ -96,7 +96,7 @@ var StageRanges = NewIntegrationTest(NewIntegrationTestArgs{
).
Press(keys.Universal.Remove).
Tap(func() {
t.Actions().ConfirmDiscardLines()
t.Common().ConfirmDiscardLines()
}).
ContainsLines(
Contains("+three"),

View File

@@ -12,7 +12,7 @@ var Add = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.RunCommand("git clone --bare . ../other_repo")
shell.Clone("other_repo")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Submodules().Focus().

View File

@@ -20,8 +20,7 @@ var Enter = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.RunCommand("git clone --bare . ../other_repo")
shell.RunCommand("git submodule add ../other_repo my_submodule")
shell.CloneIntoSubmodule("my_submodule")
shell.GitAddAll()
shell.Commit("add submodule")
},

View File

@@ -12,8 +12,7 @@ var Remove = NewIntegrationTest(NewIntegrationTestArgs{
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.RunCommand("git clone --bare . ../other_repo")
shell.RunCommand("git submodule add ../other_repo my_submodule")
shell.CloneIntoSubmodule("my_submodule")
shell.GitAddAll()
shell.Commit("add submodule")
},

View File

@@ -20,8 +20,7 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("first commit")
shell.RunCommand("git clone --bare . ../other_repo")
shell.RunCommand("git submodule add ../other_repo my_submodule")
shell.CloneIntoSubmodule("my_submodule")
shell.GitAddAll()
shell.Commit("add submodule")
},

View File

@@ -5,25 +5,6 @@ import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func createTwoBranchesReadyToForcePush(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.NewBranch("other_branch")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.SetBranchUpstream("other_branch", "origin/other_branch")
// remove the 'two' commit so that we have something to pull from the remote
shell.HardReset("HEAD^")
shell.Checkout("master")
// doing the same for master
shell.HardReset("HEAD^")
}
var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Force push to only the upstream branch of the current branch because the user has push.default upstream",
ExtraCmdArgs: "",

View File

@@ -40,7 +40,7 @@ var PullMergeConflict = NewIntegrationTest(NewIntegrationTestArgs{
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@@ -60,7 +60,7 @@ var PullMergeConflict = NewIntegrationTest(NewIntegrationTestArgs{
).
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑2 repo → master"))

View File

@@ -40,7 +40,7 @@ var PullRebaseConflict = NewIntegrationTest(NewIntegrationTestArgs{
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Files().
IsFocused().
@@ -61,7 +61,7 @@ var PullRebaseConflict = NewIntegrationTest(NewIntegrationTestArgs{
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑1 repo → master"))

View File

@@ -42,7 +42,7 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Commits().
Lines(
@@ -71,7 +71,7 @@ var PullRebaseInteractiveConflict = NewIntegrationTest(NewIntegrationTestArgs{
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑2 repo → master"))

View File

@@ -42,7 +42,7 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg
IsFocused().
Press(keys.Universal.Pull)
t.Actions().AcknowledgeConflicts()
t.Common().AcknowledgeConflicts()
t.Views().Commits().
Focus().
@@ -79,7 +79,7 @@ var PullRebaseInteractiveConflictDrop = NewIntegrationTest(NewIntegrationTestArg
SelectNextItem().
PressPrimaryAction() // choose 'content4'
t.Actions().ContinueOnConflictsResolved()
t.Common().ContinueOnConflictsResolved()
t.Views().Status().Content(Contains("↑1 repo → master"))

View File

@@ -30,28 +30,3 @@ var Push = NewIntegrationTest(NewIntegrationTestArgs{
assertSuccessfullyPushed(t)
},
})
func assertSuccessfullyPushed(t *TestDriver) {
t.Views().Status().Content(Contains("✓ repo → master"))
t.Views().Remotes().
Focus().
Lines(
Contains("origin"),
).
PressEnter()
t.Views().RemoteBranches().
IsFocused().
Lines(
Contains("master"),
).
PressEnter()
t.Views().SubCommits().
IsFocused().
Lines(
Contains("two"),
Contains("one"),
)
}

View File

@@ -23,8 +23,7 @@ var PushWithCredentialPrompt = NewIntegrationTest(NewIntegrationTestArgs{
// actually getting a password prompt is tricky: it requires SSH'ing into localhost under a newly created, restricted, user.
// This is not easy to do in a cross-platform way, nor is it easy to do in a docker container.
// If you can think of a way to do it, please let me know!
shell.RunCommand("cp ../../../../../hooks/pre-push .git/hooks/pre-push")
shell.RunCommand("chmod +x .git/hooks/pre-push")
shell.CopyHelpFile("pre-push", ".git/hooks/pre-push")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Status().Content(Contains("↑1 repo → master"))

View File

@@ -0,0 +1,49 @@
package sync
import (
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
func createTwoBranchesReadyToForcePush(shell *Shell) {
shell.EmptyCommit("one")
shell.EmptyCommit("two")
shell.NewBranch("other_branch")
shell.CloneIntoRemote("origin")
shell.SetBranchUpstream("master", "origin/master")
shell.SetBranchUpstream("other_branch", "origin/other_branch")
// remove the 'two' commit so that we have something to pull from the remote
shell.HardReset("HEAD^")
shell.Checkout("master")
// doing the same for master
shell.HardReset("HEAD^")
}
func assertSuccessfullyPushed(t *TestDriver) {
t.Views().Status().Content(Contains("✓ repo → master"))
t.Views().Remotes().
Focus().
Lines(
Contains("origin"),
).
PressEnter()
t.Views().RemoteBranches().
IsFocused().
Lines(
Contains("master"),
).
PressEnter()
t.Views().SubCommits().
IsFocused().
Lines(
Contains("two"),
Contains("one"),
)
}

View File

@@ -1,7 +1,7 @@
//go:build ignore
// This file is invoked with `go generate ./...` and it generates the tests_gen.go file
// The tests_gen.go file is a list of all the integration tests.
// This file is invoked with `go generate ./...` and it generates the test_list.go file
// The test_list.go file is a list of all the integration tests.
// It's annoying to have to manually add an entry in that file for each test you
// create, so this generator is here to make the process easier.
@@ -26,7 +26,7 @@ func main() {
if err != nil {
panic(err)
}
if err := ioutil.WriteFile("tests_gen.go", formattedCode, 0o644); err != nil {
if err := ioutil.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
panic(err)
}
}

View File

@@ -1,4 +1,4 @@
//go:generate go run tests_generator.go
//go:generate go run test_list_generator.go
package tests
@@ -30,7 +30,7 @@ func GetTests() []*components.IntegrationTest {
if err := filepath.Walk(filepath.Join(utils.GetLazyRootDirectory(), "pkg/integration/tests"), func(path string, info os.FileInfo, err error) error {
if !info.IsDir() && strings.HasSuffix(path, ".go") {
// ignoring non-test files
if filepath.Base(path) == "tests.go" || filepath.Base(path) == "tests_gen.go" || filepath.Base(path) == "tests_generator.go" {
if filepath.Base(path) == "tests.go" || filepath.Base(path) == "test_list.go" || filepath.Base(path) == "test_list_generator.go" {
return nil
}
@@ -39,6 +39,11 @@ func GetTests() []*components.IntegrationTest {
return nil
}
// any file named shared.go will also be ignored, because those files are only used for shared helper functions
if filepath.Base(path) == "shared.go" {
return nil
}
nameFromPath := components.TestNameFromFilePath(path)
if !testNamesSet.Includes(nameFromPath) {
missingTestNames = append(missingTestNames, nameFromPath)
@@ -51,13 +56,13 @@ func GetTests() []*components.IntegrationTest {
}
if len(missingTestNames) > 0 {
panic(fmt.Sprintf("The following tests are missing from the list of tests: %s. You need to add them to `pkg/integration/tests/tests_gen.go`. Use `go generate ./...` to regenerate the tests list.", strings.Join(missingTestNames, ", ")))
panic(fmt.Sprintf("The following tests are missing from the list of tests: %s. You need to add them to `pkg/integration/tests/test_list.go`. Use `go generate ./...` to regenerate the tests list.", strings.Join(missingTestNames, ", ")))
}
if testCount > len(tests) {
panic("you have not added all of the tests to the tests list in `pkg/integration/tests/tests_gen.go`. Use `go generate ./...` to regenerate the tests list.")
panic("you have not added all of the tests to the tests list in `pkg/integration/tests/test_list.go`. Use `go generate ./...` to regenerate the tests list.")
} else if testCount < len(tests) {
panic("There are more tests in `pkg/integration/tests/tests_gen.go` than there are test files in the tests directory. Ensure that you only have one test per file and you haven't included the same test twice in the tests list. Use `go generate ./...` to regenerate the tests list.")
panic("There are more tests in `pkg/integration/tests/test_list.go` than there are test files in the tests directory. Ensure that you only have one test per file and you haven't included the same test twice in the tests list. Use `go generate ./...` to regenerate the tests list.")
}
return tests