From fa0414777fcf266a05b777e2e8b7d487fd56f376 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 26 Dec 2022 10:42:19 +1100 Subject: [PATCH] rename SelectedLine to CurrentLine in tests --- pkg/integration/components/assert.go | 4 ++-- pkg/integration/components/input.go | 10 +++++----- pkg/integration/tests/bisect/basic.go | 12 ++++++------ pkg/integration/tests/branch/checkout_by_name.go | 2 +- pkg/integration/tests/branch/delete.go | 2 +- pkg/integration/tests/branch/rebase.go | 2 +- pkg/integration/tests/branch/rebase_and_drop.go | 6 +++--- .../tests/cherry_pick/cherry_pick_conflicts.go | 2 +- pkg/integration/tests/commit/staged.go | 2 +- pkg/integration/tests/commit/staged_without_hooks.go | 2 +- pkg/integration/tests/commit/unstaged.go | 2 +- pkg/integration/tests/custom_commands/basic.go | 2 +- .../tests/custom_commands/form_prompts.go | 2 +- .../tests/custom_commands/menu_from_command.go | 2 +- .../custom_commands/menu_from_commands_output.go | 2 +- .../tests/custom_commands/multiple_prompts.go | 2 +- pkg/integration/tests/diff/diff.go | 4 ++-- pkg/integration/tests/diff/diff_and_apply_patch.go | 6 +++--- pkg/integration/tests/diff/diff_commits.go | 4 ++-- pkg/integration/tests/file/discard_changes.go | 2 +- pkg/integration/tests/interactive_rebase/one.go | 8 ++++---- pkg/integration/tests/stash/rename.go | 2 +- 22 files changed, 41 insertions(+), 41 deletions(-) diff --git a/pkg/integration/components/assert.go b/pkg/integration/components/assert.go index 162b4a070..c81e25fab 100644 --- a/pkg/integration/components/assert.go +++ b/pkg/integration/components/assert.go @@ -143,7 +143,7 @@ func (self *Assert) InListContext() { }) } -func (self *Assert) SelectedLine(matcher *matcher) { +func (self *Assert) CurrentLine(matcher *matcher) { self.matchString(matcher, "Unexpected selected line.", func() string { return self.gui.CurrentContext().GetView().SelectedLine() @@ -151,7 +151,7 @@ func (self *Assert) SelectedLine(matcher *matcher) { ) } -func (self *Assert) SelectedLineIdx(expected int) { +func (self *Assert) CurrentLineIdx(expected int) { self.assertWithRetries(func() (bool, string) { actual := self.gui.CurrentContext().GetView().SelectedLineIdx() return expected == actual, fmt.Sprintf("Expected selected line index to be %d, got %d", expected, actual) diff --git a/pkg/integration/components/input.go b/pkg/integration/components/input.go index b6f2022c6..5905e2087 100644 --- a/pkg/integration/components/input.go +++ b/pkg/integration/components/input.go @@ -103,7 +103,7 @@ func (self *Input) PreviousItem() { func (self *Input) ContinueMerge() { self.Press(self.keys.Universal.CreateRebaseOptionsMenu) - self.assert.SelectedLine(Contains("continue")) + self.assert.CurrentLine(Contains("continue")) self.Confirm() } @@ -166,20 +166,20 @@ func (self *Input) NavigateToListItem(matcher *matcher) { selectedLineIdx := view.SelectedLineIdx() if selectedLineIdx == matchIndex { - self.assert.SelectedLine(matcher) + self.assert.CurrentLine(matcher) return } if selectedLineIdx < matchIndex { for i := selectedLineIdx; i < matchIndex; i++ { self.NextItem() } - self.assert.SelectedLine(matcher) + self.assert.CurrentLine(matcher) return } else { for i := selectedLineIdx; i > matchIndex; i-- { self.PreviousItem() } - self.assert.SelectedLine(matcher) + self.assert.CurrentLine(matcher) return } } @@ -213,7 +213,7 @@ func (self *Input) Typeahead(title *matcher, textToType string, expectedFirstOpt self.Type(textToType) self.Press(self.keys.Universal.TogglePanel) self.assert.CurrentViewName("suggestions") - self.assert.SelectedLine(expectedFirstOption) + self.assert.CurrentLine(expectedFirstOption) self.Confirm() } diff --git a/pkg/integration/tests/bisect/basic.go b/pkg/integration/tests/bisect/basic.go index f40b4fe39..eb44fa2ab 100644 --- a/pkg/integration/tests/bisect/basic.go +++ b/pkg/integration/tests/bisect/basic.go @@ -34,7 +34,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ input.SwitchToCommitsWindow() - assert.SelectedLine(Contains("commit 10")) + assert.CurrentLine(Contains("commit 10")) input.NavigateToListItem(Contains("commit 09")) @@ -43,7 +43,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ assert.ViewContent("information", Contains("bisecting")) assert.CurrentViewName("commits") - assert.SelectedLine(Contains("<-- bad")) + assert.CurrentLine(Contains("<-- bad")) input.NavigateToListItem(Contains("commit 02")) @@ -51,14 +51,14 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ // lazygit will land us in the commit between our good and bad commits. assert.CurrentViewName("commits") - assert.SelectedLine(Contains("commit 05")) - assert.SelectedLine(Contains("<-- current")) + assert.CurrentLine(Contains("commit 05")) + assert.CurrentLine(Contains("<-- current")) markCommitAsBad() assert.CurrentViewName("commits") - assert.SelectedLine(Contains("commit 04")) - assert.SelectedLine(Contains("<-- current")) + assert.CurrentLine(Contains("commit 04")) + assert.CurrentLine(Contains("<-- current")) markCommitAsGood() diff --git a/pkg/integration/tests/branch/checkout_by_name.go b/pkg/integration/tests/branch/checkout_by_name.go index e34215037..652a1c58e 100644 --- a/pkg/integration/tests/branch/checkout_by_name.go +++ b/pkg/integration/tests/branch/checkout_by_name.go @@ -40,6 +40,6 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{ Contains("@"), ) - assert.SelectedLine(Contains("new-branch")) + assert.CurrentLine(Contains("new-branch")) }, }) diff --git a/pkg/integration/tests/branch/delete.go b/pkg/integration/tests/branch/delete.go index 5192f1035..55e9b6aa5 100644 --- a/pkg/integration/tests/branch/delete.go +++ b/pkg/integration/tests/branch/delete.go @@ -39,6 +39,6 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{ MatchesRegexp(`\*.*branch-two`), MatchesRegexp(`master`), ) - assert.SelectedLineIdx(1) + assert.CurrentLineIdx(1) }, }) diff --git a/pkg/integration/tests/branch/rebase.go b/pkg/integration/tests/branch/rebase.go index 96e3c1d72..8e60bd876 100644 --- a/pkg/integration/tests/branch/rebase.go +++ b/pkg/integration/tests/branch/rebase.go @@ -39,7 +39,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{ input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!")) assert.CurrentViewName("files") - assert.SelectedLine(Contains("file")) + assert.CurrentLine(Contains("file")) // not using Confirm() convenience method because I suspect we might change this // keybinding to something more bespoke diff --git a/pkg/integration/tests/branch/rebase_and_drop.go b/pkg/integration/tests/branch/rebase_and_drop.go index 284f80f05..cb113997b 100644 --- a/pkg/integration/tests/branch/rebase_and_drop.go +++ b/pkg/integration/tests/branch/rebase_and_drop.go @@ -46,7 +46,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!")) assert.CurrentViewName("files") - assert.SelectedLine(Contains("file")) + assert.CurrentLine(Contains("file")) input.SwitchToCommitsWindow() assert.ViewTopLines( @@ -57,10 +57,10 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ MatchesRegexp("second change"), MatchesRegexp("original"), ) - assert.SelectedLineIdx(0) + assert.CurrentLineIdx(0) input.NextItem() input.Press(keys.Universal.Remove) - assert.SelectedLine(MatchesRegexp(`drop.*to remove`)) + assert.CurrentLine(MatchesRegexp(`drop.*to remove`)) input.SwitchToFilesWindow() diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index 6a9c47781..4095a563f 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -55,7 +55,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ input.AcceptConfirmation(Equals("Auto-merge failed"), Contains("Conflicts!")) assert.CurrentViewName("files") - assert.SelectedLine(Contains("file")) + assert.CurrentLine(Contains("file")) // not using Confirm() convenience method because I suspect we might change this // keybinding to something more bespoke diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go index acce2c76a..b39ab1b38 100644 --- a/pkg/integration/tests/commit/staged.go +++ b/pkg/integration/tests/commit/staged.go @@ -19,7 +19,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{ assert.CommitCount(0) assert.CurrentViewName("files") - assert.SelectedLine(Contains("myfile")) + assert.CurrentLine(Contains("myfile")) // stage the file input.PrimaryAction() input.Enter() diff --git a/pkg/integration/tests/commit/staged_without_hooks.go b/pkg/integration/tests/commit/staged_without_hooks.go index bb0cba3c5..cc7b4bcaf 100644 --- a/pkg/integration/tests/commit/staged_without_hooks.go +++ b/pkg/integration/tests/commit/staged_without_hooks.go @@ -20,7 +20,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ // stage the file assert.CurrentViewName("files") - assert.SelectedLine(Contains("myfile")) + assert.CurrentLine(Contains("myfile")) input.PrimaryAction() input.Enter() assert.CurrentViewName("stagingSecondary") diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go index 92be9615b..7b12de6a3 100644 --- a/pkg/integration/tests/commit/unstaged.go +++ b/pkg/integration/tests/commit/unstaged.go @@ -21,7 +21,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ assert.CommitCount(0) assert.CurrentViewName("files") - assert.SelectedLine(Contains("myfile")) + assert.CurrentLine(Contains("myfile")) input.Enter() assert.CurrentViewName("staging") assert.ViewContent("stagingSecondary", NotContains("+myfile content")) diff --git a/pkg/integration/tests/custom_commands/basic.go b/pkg/integration/tests/custom_commands/basic.go index a97bdef4a..dfddb6d8c 100644 --- a/pkg/integration/tests/custom_commands/basic.go +++ b/pkg/integration/tests/custom_commands/basic.go @@ -31,6 +31,6 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ input.Press("a") assert.WorkingTreeFileCount(1) - assert.SelectedLine(Contains("myfile")) + assert.CurrentLine(Contains("myfile")) }, }) diff --git a/pkg/integration/tests/custom_commands/form_prompts.go b/pkg/integration/tests/custom_commands/form_prompts.go index e0502fbae..bfe559bf7 100644 --- a/pkg/integration/tests/custom_commands/form_prompts.go +++ b/pkg/integration/tests/custom_commands/form_prompts.go @@ -72,7 +72,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{ input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy.")) assert.WorkingTreeFileCount(1) - assert.SelectedLine(Contains("my file")) + assert.CurrentLine(Contains("my file")) assert.MainViewContent(Contains(`"BAR"`)) }, }) diff --git a/pkg/integration/tests/custom_commands/menu_from_command.go b/pkg/integration/tests/custom_commands/menu_from_command.go index 5d8fee71a..b75d77ef3 100644 --- a/pkg/integration/tests/custom_commands/menu_from_command.go +++ b/pkg/integration/tests/custom_commands/menu_from_command.go @@ -60,7 +60,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ input.SwitchToFilesWindow() assert.WorkingTreeFileCount(1) - assert.SelectedLine(Contains("output.txt")) + assert.CurrentLine(Contains("output.txt")) assert.MainViewContent(Contains("bar Branch: #feature/foo my branch feature/foo")) }, }) diff --git a/pkg/integration/tests/custom_commands/menu_from_commands_output.go b/pkg/integration/tests/custom_commands/menu_from_commands_output.go index 1a7860ebb..c4768aca0 100644 --- a/pkg/integration/tests/custom_commands/menu_from_commands_output.go +++ b/pkg/integration/tests/custom_commands/menu_from_commands_output.go @@ -56,7 +56,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{ assert.InPrompt() assert.CurrentViewTitle(Equals("Which git command do you want to run?")) - assert.SelectedLine(Equals("branch")) + assert.CurrentLine(Equals("branch")) input.Confirm() input.Menu(Equals("Branch:"), Equals("master")) diff --git a/pkg/integration/tests/custom_commands/multiple_prompts.go b/pkg/integration/tests/custom_commands/multiple_prompts.go index 5e6ebb6a2..ccb234f16 100644 --- a/pkg/integration/tests/custom_commands/multiple_prompts.go +++ b/pkg/integration/tests/custom_commands/multiple_prompts.go @@ -70,7 +70,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{ input.AcceptConfirmation(Equals("Are you sure?"), Equals("Are you REALLY sure you want to make this file? Up to you buddy.")) assert.WorkingTreeFileCount(1) - assert.SelectedLine(Contains("myfile")) + assert.CurrentLine(Contains("myfile")) assert.MainViewContent(Contains("BAR")) }, }) diff --git a/pkg/integration/tests/diff/diff.go b/pkg/integration/tests/diff/diff.go index da666377d..b9f88858c 100644 --- a/pkg/integration/tests/diff/diff.go +++ b/pkg/integration/tests/diff/diff.go @@ -42,10 +42,10 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{ input.Enter() assert.CurrentViewName("subCommits") assert.MainViewContent(Contains("+second line")) - assert.SelectedLine(Contains("update")) + assert.CurrentLine(Contains("update")) input.Enter() assert.CurrentViewName("commitFiles") - assert.SelectedLine(Contains("file1")) + assert.CurrentLine(Contains("file1")) assert.MainViewContent(Contains("+second line")) input.Press(keys.Universal.Return) diff --git a/pkg/integration/tests/diff/diff_and_apply_patch.go b/pkg/integration/tests/diff/diff_and_apply_patch.go index c5d2b3e6e..0091579da 100644 --- a/pkg/integration/tests/diff/diff_and_apply_patch.go +++ b/pkg/integration/tests/diff/diff_and_apply_patch.go @@ -43,10 +43,10 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ input.Enter() assert.CurrentViewName("subCommits") assert.MainViewContent(Contains("+second line")) - assert.SelectedLine(Contains("update")) + assert.CurrentLine(Contains("update")) input.Enter() assert.CurrentViewName("commitFiles") - assert.SelectedLine(Contains("file1")) + assert.CurrentLine(Contains("file1")) assert.MainViewContent(Contains("+second line")) // add the file to the patch @@ -63,7 +63,7 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ input.SwitchToFilesWindow() - assert.SelectedLine(Contains("file1")) + assert.CurrentLine(Contains("file1")) assert.MainViewContent(Contains("+second line")) }, }) diff --git a/pkg/integration/tests/diff/diff_commits.go b/pkg/integration/tests/diff/diff_commits.go index 39bf54d6f..03523de59 100644 --- a/pkg/integration/tests/diff/diff_commits.go +++ b/pkg/integration/tests/diff/diff_commits.go @@ -37,7 +37,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ input.NextItem() input.NextItem() - assert.SelectedLine(Contains("first commit")) + assert.CurrentLine(Contains("first commit")) assert.MainViewContent(Contains("-second line\n-third line")) @@ -50,7 +50,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ input.Enter() assert.CurrentViewName("commitFiles") - assert.SelectedLine(Contains("file1")) + assert.CurrentLine(Contains("file1")) assert.MainViewContent(Contains("+second line\n+third line")) }, }) diff --git a/pkg/integration/tests/file/discard_changes.go b/pkg/integration/tests/file/discard_changes.go index 87e39e96b..b08fc34d8 100644 --- a/pkg/integration/tests/file/discard_changes.go +++ b/pkg/integration/tests/file/discard_changes.go @@ -82,7 +82,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{ discardOneByOne := func(files []statusFile) { for _, file := range files { - assert.SelectedLine(Contains(file.status + " " + file.label)) + assert.CurrentLine(Contains(file.status + " " + file.label)) input.Press(keys.Universal.Remove) input.Menu(Equals(file.menuTitle), Contains("discard all changes")) } diff --git a/pkg/integration/tests/interactive_rebase/one.go b/pkg/integration/tests/interactive_rebase/one.go index d516087ff..fdebd7ca8 100644 --- a/pkg/integration/tests/interactive_rebase/one.go +++ b/pkg/integration/tests/interactive_rebase/one.go @@ -20,19 +20,19 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{ input.NavigateToListItem(Contains("commit 02")) input.Press(keys.Universal.Edit) - assert.SelectedLine(Contains("YOU ARE HERE")) + assert.CurrentLine(Contains("YOU ARE HERE")) input.PreviousItem() input.Press(keys.Commits.MarkCommitAsFixup) - assert.SelectedLine(Contains("fixup")) + assert.CurrentLine(Contains("fixup")) input.PreviousItem() input.Press(keys.Universal.Remove) - assert.SelectedLine(Contains("drop")) + assert.CurrentLine(Contains("drop")) input.PreviousItem() input.Press(keys.Commits.SquashDown) - assert.SelectedLine(Contains("squash")) + assert.CurrentLine(Contains("squash")) input.ContinueRebase() diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go index de5385a56..98b16f96a 100644 --- a/pkg/integration/tests/stash/rename.go +++ b/pkg/integration/tests/stash/rename.go @@ -31,6 +31,6 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{ input.Prompt(Equals("Rename stash: stash@{1}"), " baz") - assert.SelectedLine(Equals("On master: foo baz")) + assert.CurrentLine(Equals("On master: foo baz")) }, })