From c5050ecabd57702c7bfb02a38729ed8a4f23b2c5 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 27 Dec 2022 21:47:37 +1100 Subject: move shell into test driver --- pkg/integration/components/runner.go | 2 +- pkg/integration/components/shell.go | 109 +++++++++++---------- pkg/integration/components/test.go | 13 ++- pkg/integration/components/test_driver.go | 9 +- pkg/integration/components/test_test.go | 6 +- pkg/integration/tests/bisect/basic.go | 6 +- pkg/integration/tests/bisect/from_other_branch.go | 6 +- 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 | 2 +- pkg/integration/tests/branch/reset.go | 2 +- pkg/integration/tests/branch/suggestions.go | 2 +- pkg/integration/tests/cherry_pick/cherry_pick.go | 2 +- .../tests/cherry_pick/cherry_pick_conflicts.go | 2 +- pkg/integration/tests/commit/commit.go | 2 +- pkg/integration/tests/commit/commit_multiline.go | 2 +- pkg/integration/tests/commit/new_branch.go | 2 +- pkg/integration/tests/commit/revert.go | 2 +- pkg/integration/tests/commit/staged.go | 2 +- .../tests/commit/staged_without_hooks.go | 2 +- pkg/integration/tests/commit/unstaged.go | 2 +- pkg/integration/tests/config/remote_named_star.go | 6 +- pkg/integration/tests/custom_commands/basic.go | 6 +- .../tests/custom_commands/form_prompts.go | 6 +- .../tests/custom_commands/menu_from_command.go | 6 +- .../custom_commands/menu_from_commands_output.go | 6 +- .../tests/custom_commands/multiple_prompts.go | 6 +- pkg/integration/tests/diff/diff.go | 2 +- pkg/integration/tests/diff/diff_and_apply_patch.go | 2 +- pkg/integration/tests/diff/diff_commits.go | 2 +- .../tests/file/dir_with_untracked_file.go | 2 +- pkg/integration/tests/file/discard_changes.go | 2 +- .../tests/interactive_rebase/amend_merge.go | 2 +- pkg/integration/tests/interactive_rebase/one.go | 2 +- pkg/integration/tests/misc/confirm_on_quit.go | 2 +- pkg/integration/tests/stash/rename.go | 2 +- pkg/integration/tests/stash/stash.go | 2 +- .../tests/stash/stash_including_untracked_files.go | 2 +- 39 files changed, 108 insertions(+), 131 deletions(-) diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index 85ea3f330..964ad98a5 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -126,7 +126,7 @@ func buildLazygit() error { } func createFixture(test *IntegrationTest, paths Paths) error { - shell := NewShell(paths.ActualRepo()) + shell := NewShell(paths.ActualRepo(), func(errorMsg string) { panic(errorMsg) }) shell.RunCommand("git init -b master") shell.RunCommand(`git config user.email "CI@example.com"`) shell.RunCommand(`git config user.name "CI"`) diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index d0f0345dc..3fd63c8cc 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -15,119 +15,122 @@ import ( type Shell struct { // working directory the shell is invoked in dir string + // when running the shell outside the gui we can directly panic on failure, + // but inside the gui we need to close the gui before panicking + fail func(string) } -func NewShell(dir string) *Shell { - return &Shell{dir: dir} +func NewShell(dir string, fail func(string)) *Shell { + return &Shell{dir: dir, fail: fail} } -func (s *Shell) RunCommand(cmdStr string) *Shell { +func (self *Shell) RunCommand(cmdStr string) *Shell { args := str.ToArgv(cmdStr) cmd := secureexec.Command(args[0], args[1:]...) cmd.Env = os.Environ() - cmd.Dir = s.dir + cmd.Dir = self.dir output, err := cmd.CombinedOutput() if err != nil { - panic(fmt.Sprintf("error running command: %s\n%s", cmdStr, string(output))) + self.fail(fmt.Sprintf("error running command: %s\n%s", cmdStr, string(output))) } - return s + return self } -func (s *Shell) RunShellCommand(cmdStr string) *Shell { +func (self *Shell) RunShellCommand(cmdStr string) *Shell { cmd := secureexec.Command("sh", "-c", cmdStr) cmd.Env = os.Environ() - cmd.Dir = s.dir + cmd.Dir = self.dir output, err := cmd.CombinedOutput() if err != nil { - panic(fmt.Sprintf("error running shell command: %s\n%s", cmdStr, string(output))) + self.fail(fmt.Sprintf("error running shell command: %s\n%s", cmdStr, string(output))) } - return s + return self } -func (s *Shell) RunShellCommandExpectError(cmdStr string) *Shell { +func (self *Shell) RunShellCommandExpectError(cmdStr string) *Shell { cmd := secureexec.Command("sh", "-c", cmdStr) cmd.Env = os.Environ() - cmd.Dir = s.dir + cmd.Dir = self.dir output, err := cmd.CombinedOutput() if err == nil { - panic(fmt.Sprintf("Expected error running shell command: %s\n%s", cmdStr, string(output))) + self.fail(fmt.Sprintf("Expected error running shell command: %s\n%s", cmdStr, string(output))) } - return s + return self } -func (s *Shell) CreateFile(path string, content string) *Shell { - fullPath := filepath.Join(s.dir, path) +func (self *Shell) CreateFile(path string, content string) *Shell { + fullPath := filepath.Join(self.dir, path) err := os.WriteFile(fullPath, []byte(content), 0o644) if err != nil { - panic(fmt.Sprintf("error creating file: %s\n%s", fullPath, err)) + self.fail(fmt.Sprintf("error creating file: %s\n%s", fullPath, err)) } - return s + return self } -func (s *Shell) CreateDir(path string) *Shell { - fullPath := filepath.Join(s.dir, path) +func (self *Shell) CreateDir(path string) *Shell { + fullPath := filepath.Join(self.dir, path) if err := os.MkdirAll(fullPath, 0o755); err != nil { - panic(fmt.Sprintf("error creating directory: %s\n%s", fullPath, err)) + self.fail(fmt.Sprintf("error creating directory: %s\n%s", fullPath, err)) } - return s + return self } -func (s *Shell) UpdateFile(path string, content string) *Shell { - fullPath := filepath.Join(s.dir, path) +func (self *Shell) UpdateFile(path string, content string) *Shell { + fullPath := filepath.Join(self.dir, path) err := os.WriteFile(fullPath, []byte(content), 0o644) if err != nil { - panic(fmt.Sprintf("error updating file: %s\n%s", fullPath, err)) + self.fail(fmt.Sprintf("error updating file: %s\n%s", fullPath, err)) } - return s + return self } -func (s *Shell) NewBranch(name string) *Shell { - return s.RunCommand("git checkout -b " + name) +func (self *Shell) NewBranch(name string) *Shell { + return self.RunCommand("git checkout -b " + name) } -func (s *Shell) Checkout(name string) *Shell { - return s.RunCommand("git checkout " + name) +func (self *Shell) Checkout(name string) *Shell { + return self.RunCommand("git checkout " + name) } -func (s *Shell) Merge(name string) *Shell { - return s.RunCommand("git merge --commit --no-ff " + name) +func (self *Shell) Merge(name string) *Shell { + return self.RunCommand("git merge --commit --no-ff " + name) } -func (s *Shell) GitAdd(path string) *Shell { - return s.RunCommand(fmt.Sprintf("git add \"%s\"", path)) +func (self *Shell) GitAdd(path string) *Shell { + return self.RunCommand(fmt.Sprintf("git add \"%s\"", path)) } -func (s *Shell) GitAddAll() *Shell { - return s.RunCommand("git add -A") +func (self *Shell) GitAddAll() *Shell { + return self.RunCommand("git add -A") } -func (s *Shell) Commit(message string) *Shell { - return s.RunCommand(fmt.Sprintf("git commit -m \"%s\"", message)) +func (self *Shell) Commit(message string) *Shell { + return self.RunCommand(fmt.Sprintf("git commit -m \"%s\"", message)) } -func (s *Shell) EmptyCommit(message string) *Shell { - return s.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message)) +func (self *Shell) EmptyCommit(message string) *Shell { + return self.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message)) } // convenience method for creating a file and adding it -func (s *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell { - return s. +func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell { + return self. CreateFile(fileName, fileContents). GitAdd(fileName) } // convenience method for updating a file and adding it -func (s *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell { - return s. +func (self *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell { + return self. UpdateFile(fileName, fileContents). GitAdd(fileName) } @@ -135,24 +138,24 @@ func (s *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell { // creates commits 01, 02, 03, ..., n with a new file in each // The reason for padding with zeroes is so that it's easier to do string // matches on the commit messages when there are many of them -func (s *Shell) CreateNCommits(n int) *Shell { +func (self *Shell) CreateNCommits(n int) *Shell { for i := 1; i <= n; i++ { - s.CreateFileAndAdd( + self.CreateFileAndAdd( fmt.Sprintf("file%02d.txt", i), fmt.Sprintf("file%02d content", i), ). Commit(fmt.Sprintf("commit %02d", i)) } - return s + return self } -func (s *Shell) StashWithMessage(message string) *Shell { - s.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message)) - return s +func (self *Shell) StashWithMessage(message string) *Shell { + self.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message)) + return self } -func (s *Shell) SetConfig(key string, value string) *Shell { - s.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value)) - return s +func (self *Shell) SetConfig(key string, value string) *Shell { + self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value)) + return self } diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go index 927dfb36c..0b36a12d9 100644 --- a/pkg/integration/components/test.go +++ b/pkg/integration/components/test.go @@ -24,8 +24,7 @@ type IntegrationTest struct { setupRepo func(shell *Shell) setupConfig func(config *config.AppConfig) run func( - shell *Shell, - testController *TestDriver, + testDriver *TestDriver, keys config.KeybindingConfig, ) } @@ -40,7 +39,7 @@ type NewIntegrationTestArgs struct { // takes a config and mutates. The mutated context will end up being passed to the gui SetupConfig func(config *config.AppConfig) // runs the test - Run func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) + Run func(t *TestDriver, keys config.KeybindingConfig) // additional args passed to lazygit ExtraCmdArgs string // for when a test is flakey @@ -92,15 +91,15 @@ func (self *IntegrationTest) SetupRepo(shell *Shell) { // I want access to all contexts, the model, the ability to press a key, the ability to log, func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver) { - shell := NewShell("/tmp/lazygit-test") + shell := NewShell("/tmp/lazygit-test", func(errorMsg string) { gui.Fail(errorMsg) }) keys := gui.Keys() - testController := NewTestController(gui, keys, KeyPressDelay()) + testDriver := NewTestDriver(gui, shell, keys, KeyPressDelay()) - self.run(shell, testController, keys) + self.run(testDriver, keys) if KeyPressDelay() > 0 { // the dev would want to see the final state if they're running in slow mode - testController.Wait(2000) + testDriver.Wait(2000) } } diff --git a/pkg/integration/components/test_driver.go b/pkg/integration/components/test_driver.go index 7b3fb0889..f2604d211 100644 --- a/pkg/integration/components/test_driver.go +++ b/pkg/integration/components/test_driver.go @@ -16,14 +16,16 @@ type TestDriver struct { keys config.KeybindingConfig pushKeyDelay int *assertionHelper + shell *Shell } -func NewTestController(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, pushKeyDelay int) *TestDriver { +func NewTestDriver(gui integrationTypes.GuiDriver, shell *Shell, keys config.KeybindingConfig, pushKeyDelay int) *TestDriver { return &TestDriver{ gui: gui, keys: keys, pushKeyDelay: pushKeyDelay, assertionHelper: &assertionHelper{gui: gui}, + shell: shell, } } @@ -67,6 +69,11 @@ func (self *TestDriver) Log(message string) { self.gui.LogUI(message) } +// allows the user to run shell commands during the test to emulate background activity +func (self *TestDriver) Shell() *Shell { + return self.shell +} + // this will look for a list item in the current panel and if it finds it, it will // enter the keypresses required to navigate to it. // The test will fail if: diff --git a/pkg/integration/components/test_test.go b/pkg/integration/components/test_test.go index 79d2b3955..ccab35dc8 100644 --- a/pkg/integration/components/test_test.go +++ b/pkg/integration/components/test_test.go @@ -63,7 +63,7 @@ func (self *fakeGuiDriver) View(viewName string) *gocui.View { func TestAssertionFailure(t *testing.T) { test := NewIntegrationTest(NewIntegrationTestArgs{ Description: unitTestDescription, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.press("a") t.press("b") t.Model().CommitCount(2) @@ -78,7 +78,7 @@ func TestAssertionFailure(t *testing.T) { func TestManualFailure(t *testing.T) { test := NewIntegrationTest(NewIntegrationTestArgs{ Description: unitTestDescription, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Fail("blah") }, }) @@ -90,7 +90,7 @@ func TestManualFailure(t *testing.T) { func TestSuccess(t *testing.T) { test := NewIntegrationTest(NewIntegrationTestArgs{ Description: unitTestDescription, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.press("a") t.press("b") t.Model().CommitCount(0) diff --git a/pkg/integration/tests/bisect/basic.go b/pkg/integration/tests/bisect/basic.go index cbb37aac7..8294f61a4 100644 --- a/pkg/integration/tests/bisect/basic.go +++ b/pkg/integration/tests/bisect/basic.go @@ -14,11 +14,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ CreateNCommits(10) }, SetupConfig: func(cfg *config.AppConfig) {}, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { markCommitAsBad := func() { t.Views().Commits(). Press(keys.Commits.ViewBisectOptions) diff --git a/pkg/integration/tests/bisect/from_other_branch.go b/pkg/integration/tests/bisect/from_other_branch.go index 8759e28f3..13e7e8055 100644 --- a/pkg/integration/tests/bisect/from_other_branch.go +++ b/pkg/integration/tests/bisect/from_other_branch.go @@ -18,11 +18,7 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{ RunCommand("git bisect start other~2 other~5") }, SetupConfig: func(cfg *config.AppConfig) {}, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Information().Content(Contains("bisecting")) t.Model().AtLeastOneCommit() diff --git a/pkg/integration/tests/branch/checkout_by_name.go b/pkg/integration/tests/branch/checkout_by_name.go index 7a8733d26..c786f8970 100644 --- a/pkg/integration/tests/branch/checkout_by_name.go +++ b/pkg/integration/tests/branch/checkout_by_name.go @@ -17,7 +17,7 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{ Checkout("master"). EmptyCommit("blah") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/branch/delete.go b/pkg/integration/tests/branch/delete.go index 6410576e8..520923cd6 100644 --- a/pkg/integration/tests/branch/delete.go +++ b/pkg/integration/tests/branch/delete.go @@ -16,7 +16,7 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{ NewBranch("branch-one"). NewBranch("branch-two") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/branch/rebase.go b/pkg/integration/tests/branch/rebase.go index b90810b82..137bada27 100644 --- a/pkg/integration/tests/branch/rebase.go +++ b/pkg/integration/tests/branch/rebase.go @@ -14,7 +14,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{ SetupRepo: func(shell *Shell) { shared.MergeConflictsSetup(shell) }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits().TopLines( Contains("first change"), Contains("original"), diff --git a/pkg/integration/tests/branch/rebase_and_drop.go b/pkg/integration/tests/branch/rebase_and_drop.go index 610bb1c19..dc1cfddea 100644 --- a/pkg/integration/tests/branch/rebase_and_drop.go +++ b/pkg/integration/tests/branch/rebase_and_drop.go @@ -17,7 +17,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{ shell.EmptyCommit("to remove") shell.EmptyCommit("to keep") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/branch/reset.go b/pkg/integration/tests/branch/reset.go index bfd1b950f..65a10e31b 100644 --- a/pkg/integration/tests/branch/reset.go +++ b/pkg/integration/tests/branch/reset.go @@ -20,7 +20,7 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{ shell.Checkout("current-branch") shell.EmptyCommit("current-branch commit") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits().Lines( Contains("current-branch commit"), Contains("root commit"), diff --git a/pkg/integration/tests/branch/suggestions.go b/pkg/integration/tests/branch/suggestions.go index 438bbf9be..65c64fa6d 100644 --- a/pkg/integration/tests/branch/suggestions.go +++ b/pkg/integration/tests/branch/suggestions.go @@ -20,7 +20,7 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{ NewBranch("other-new-branch-2"). NewBranch("other-new-branch-3") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Press(keys.Branches.CheckoutBranchByName) diff --git a/pkg/integration/tests/cherry_pick/cherry_pick.go b/pkg/integration/tests/cherry_pick/cherry_pick.go index 5fa2d47ac..a9d7dd9c7 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick.go @@ -23,7 +23,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ EmptyCommit("four"). Checkout("first-branch") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index 5de63baa6..5eef30b50 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -14,7 +14,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ SetupRepo: func(shell *Shell) { shared.MergeConflictsSetup(shell) }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/commit/commit.go b/pkg/integration/tests/commit/commit.go index 951529cea..5950545e7 100644 --- a/pkg/integration/tests/commit/commit.go +++ b/pkg/integration/tests/commit/commit.go @@ -14,7 +14,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("myfile", "myfile content") shell.CreateFile("myfile2", "myfile2 content") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/commit/commit_multiline.go b/pkg/integration/tests/commit/commit_multiline.go index 823412f68..11876e09a 100644 --- a/pkg/integration/tests/commit/commit_multiline.go +++ b/pkg/integration/tests/commit/commit_multiline.go @@ -13,7 +13,7 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{ SetupRepo: func(shell *Shell) { shell.CreateFile("myfile", "myfile content") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/commit/new_branch.go b/pkg/integration/tests/commit/new_branch.go index f2deecdc9..6f528ff4c 100644 --- a/pkg/integration/tests/commit/new_branch.go +++ b/pkg/integration/tests/commit/new_branch.go @@ -16,7 +16,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{ EmptyCommit("commit 2"). EmptyCommit("commit 3") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(3) t.Views().Commits(). diff --git a/pkg/integration/tests/commit/revert.go b/pkg/integration/tests/commit/revert.go index c2f3b9a52..bee657380 100644 --- a/pkg/integration/tests/commit/revert.go +++ b/pkg/integration/tests/commit/revert.go @@ -15,7 +15,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{ shell.GitAddAll() shell.Commit("first commit") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(1) t.Views().Commits(). diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go index 559231f53..d0698192a 100644 --- a/pkg/integration/tests/commit/staged.go +++ b/pkg/integration/tests/commit/staged.go @@ -15,7 +15,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/commit/staged_without_hooks.go b/pkg/integration/tests/commit/staged_without_hooks.go index be0d43904..8a6b0d3d0 100644 --- a/pkg/integration/tests/commit/staged_without_hooks.go +++ b/pkg/integration/tests/commit/staged_without_hooks.go @@ -15,7 +15,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) // stage the file diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go index 69eb4e814..3e0d68617 100644 --- a/pkg/integration/tests/commit/unstaged.go +++ b/pkg/integration/tests/commit/unstaged.go @@ -17,7 +17,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ CreateFile("myfile", "myfile content\nwith a second line"). CreateFile("myfile2", "myfile2 content") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/config/remote_named_star.go b/pkg/integration/tests/config/remote_named_star.go index 3cba2fd8a..0306427ca 100644 --- a/pkg/integration/tests/config/remote_named_star.go +++ b/pkg/integration/tests/config/remote_named_star.go @@ -15,11 +15,7 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{ CreateNCommits(2) }, SetupConfig: func(cfg *config.AppConfig) {}, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { // here we're just asserting that we haven't panicked upon starting lazygit t.Model().AtLeastOneCommit() }, diff --git a/pkg/integration/tests/custom_commands/basic.go b/pkg/integration/tests/custom_commands/basic.go index fd20f79e6..a73fab5a9 100644 --- a/pkg/integration/tests/custom_commands/basic.go +++ b/pkg/integration/tests/custom_commands/basic.go @@ -21,11 +21,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{ }, } }, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().WorkingTreeFileCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/custom_commands/form_prompts.go b/pkg/integration/tests/custom_commands/form_prompts.go index 9ede837ce..b35455368 100644 --- a/pkg/integration/tests/custom_commands/form_prompts.go +++ b/pkg/integration/tests/custom_commands/form_prompts.go @@ -55,11 +55,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{ }, } }, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().WorkingTreeFileCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/custom_commands/menu_from_command.go b/pkg/integration/tests/custom_commands/menu_from_command.go index 77d6621db..580022521 100644 --- a/pkg/integration/tests/custom_commands/menu_from_command.go +++ b/pkg/integration/tests/custom_commands/menu_from_command.go @@ -42,11 +42,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{ }, } }, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().WorkingTreeFileCount(0) t.Views().Branches(). Focus(). 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 c64b35e6e..a9a899341 100644 --- a/pkg/integration/tests/custom_commands/menu_from_commands_output.go +++ b/pkg/integration/tests/custom_commands/menu_from_commands_output.go @@ -41,11 +41,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{ }, } }, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CurrentBranchName("feature/bar") t.Model().WorkingTreeFileCount(0) diff --git a/pkg/integration/tests/custom_commands/multiple_prompts.go b/pkg/integration/tests/custom_commands/multiple_prompts.go index 9bdcc2e11..fa69169aa 100644 --- a/pkg/integration/tests/custom_commands/multiple_prompts.go +++ b/pkg/integration/tests/custom_commands/multiple_prompts.go @@ -53,11 +53,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{ }, } }, - Run: func( - shell *Shell, - t *TestDriver, - keys config.KeybindingConfig, - ) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().WorkingTreeFileCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/diff/diff.go b/pkg/integration/tests/diff/diff.go index d8f679aa0..7d66cc49d 100644 --- a/pkg/integration/tests/diff/diff.go +++ b/pkg/integration/tests/diff/diff.go @@ -21,7 +21,7 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{ shell.Checkout("branch-a") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). TopLines( diff --git a/pkg/integration/tests/diff/diff_and_apply_patch.go b/pkg/integration/tests/diff/diff_and_apply_patch.go index 4777a92da..94cd29a6c 100644 --- a/pkg/integration/tests/diff/diff_and_apply_patch.go +++ b/pkg/integration/tests/diff/diff_and_apply_patch.go @@ -21,7 +21,7 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{ shell.Checkout("branch-a") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Branches(). Focus(). Lines( diff --git a/pkg/integration/tests/diff/diff_commits.go b/pkg/integration/tests/diff/diff_commits.go index d67dcf3a6..68d4e99fd 100644 --- a/pkg/integration/tests/diff/diff_commits.go +++ b/pkg/integration/tests/diff/diff_commits.go @@ -18,7 +18,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{ shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n") shell.Commit("third commit") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( diff --git a/pkg/integration/tests/file/dir_with_untracked_file.go b/pkg/integration/tests/file/dir_with_untracked_file.go index 56128aabb..e94d237d9 100644 --- a/pkg/integration/tests/file/dir_with_untracked_file.go +++ b/pkg/integration/tests/file/dir_with_untracked_file.go @@ -21,7 +21,7 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("dir/untracked", "bar") shell.UpdateFile("dir/file", "baz") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(1) t.Views().Main(). diff --git a/pkg/integration/tests/file/discard_changes.go b/pkg/integration/tests/file/discard_changes.go index 785d8558e..ab08ff9b9 100644 --- a/pkg/integration/tests/file/discard_changes.go +++ b/pkg/integration/tests/file/discard_changes.go @@ -71,7 +71,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{ shell.RunShellCommand(`echo "renamed\nhaha" > renamed2.txt && git add renamed2.txt`) }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(3) type statusFile struct { diff --git a/pkg/integration/tests/interactive_rebase/amend_merge.go b/pkg/integration/tests/interactive_rebase/amend_merge.go index 76639ef46..1f09af0de 100644 --- a/pkg/integration/tests/interactive_rebase/amend_merge.go +++ b/pkg/integration/tests/interactive_rebase/amend_merge.go @@ -27,7 +27,7 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{ Merge("feature-branch"). CreateFileAndAdd(postMergeFilename, postMergeFileContent) }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(3) mergeCommitMessage := "Merge branch 'feature-branch' into development-branch" diff --git a/pkg/integration/tests/interactive_rebase/one.go b/pkg/integration/tests/interactive_rebase/one.go index 909dd7a82..fdfc2db52 100644 --- a/pkg/integration/tests/interactive_rebase/one.go +++ b/pkg/integration/tests/interactive_rebase/one.go @@ -14,7 +14,7 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{ shell. CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01 }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Commits(). Focus(). Lines( diff --git a/pkg/integration/tests/misc/confirm_on_quit.go b/pkg/integration/tests/misc/confirm_on_quit.go index 6699d2db3..109ece2c9 100644 --- a/pkg/integration/tests/misc/confirm_on_quit.go +++ b/pkg/integration/tests/misc/confirm_on_quit.go @@ -13,7 +13,7 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{ config.UserConfig.ConfirmOnQuit = true }, SetupRepo: func(shell *Shell) {}, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().CommitCount(0) t.Views().Files(). diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go index 5f48c80a2..fded5041c 100644 --- a/pkg/integration/tests/stash/rename.go +++ b/pkg/integration/tests/stash/rename.go @@ -18,7 +18,7 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{ CreateFileAndAdd("file-2", "change to stash2"). StashWithMessage("bar") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Views().Stash(). Focus(). Lines( diff --git a/pkg/integration/tests/stash/stash.go b/pkg/integration/tests/stash/stash.go index 16c51537a..4265e0c23 100644 --- a/pkg/integration/tests/stash/stash.go +++ b/pkg/integration/tests/stash/stash.go @@ -15,7 +15,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("file", "content") shell.GitAddAll() }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().StashCount(0) t.Model().WorkingTreeFileCount(1) diff --git a/pkg/integration/tests/stash/stash_including_untracked_files.go b/pkg/integration/tests/stash/stash_including_untracked_files.go index cc38f2ee8..d46d7fb1d 100644 --- a/pkg/integration/tests/stash/stash_including_untracked_files.go +++ b/pkg/integration/tests/stash/stash_including_untracked_files.go @@ -16,7 +16,7 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{ shell.CreateFile("file_2", "content") shell.GitAdd("file_1") }, - Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) { + Run: func(t *TestDriver, keys config.KeybindingConfig) { t.Model().StashCount(0) t.Model().WorkingTreeFileCount(2) -- cgit v1.2.3