mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
move shell into test driver
This commit is contained in:
parent
78b495f50a
commit
c5050ecabd
@ -126,7 +126,7 @@ func buildLazygit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createFixture(test *IntegrationTest, paths Paths) 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 init -b master")
|
||||||
shell.RunCommand(`git config user.email "CI@example.com"`)
|
shell.RunCommand(`git config user.email "CI@example.com"`)
|
||||||
shell.RunCommand(`git config user.name "CI"`)
|
shell.RunCommand(`git config user.name "CI"`)
|
||||||
|
@ -15,119 +15,122 @@ import (
|
|||||||
type Shell struct {
|
type Shell struct {
|
||||||
// working directory the shell is invoked in
|
// working directory the shell is invoked in
|
||||||
dir string
|
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 {
|
func NewShell(dir string, fail func(string)) *Shell {
|
||||||
return &Shell{dir: dir}
|
return &Shell{dir: dir, fail: fail}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) RunCommand(cmdStr string) *Shell {
|
func (self *Shell) RunCommand(cmdStr string) *Shell {
|
||||||
args := str.ToArgv(cmdStr)
|
args := str.ToArgv(cmdStr)
|
||||||
cmd := secureexec.Command(args[0], args[1:]...)
|
cmd := secureexec.Command(args[0], args[1:]...)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Dir = s.dir
|
cmd.Dir = self.dir
|
||||||
|
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
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 := secureexec.Command("sh", "-c", cmdStr)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Dir = s.dir
|
cmd.Dir = self.dir
|
||||||
|
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
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 := secureexec.Command("sh", "-c", cmdStr)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Dir = s.dir
|
cmd.Dir = self.dir
|
||||||
|
|
||||||
output, err := cmd.CombinedOutput()
|
output, err := cmd.CombinedOutput()
|
||||||
if err == nil {
|
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 {
|
func (self *Shell) CreateFile(path string, content string) *Shell {
|
||||||
fullPath := filepath.Join(s.dir, path)
|
fullPath := filepath.Join(self.dir, path)
|
||||||
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||||
if err != nil {
|
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 {
|
func (self *Shell) CreateDir(path string) *Shell {
|
||||||
fullPath := filepath.Join(s.dir, path)
|
fullPath := filepath.Join(self.dir, path)
|
||||||
if err := os.MkdirAll(fullPath, 0o755); err != nil {
|
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 {
|
func (self *Shell) UpdateFile(path string, content string) *Shell {
|
||||||
fullPath := filepath.Join(s.dir, path)
|
fullPath := filepath.Join(self.dir, path)
|
||||||
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||||
if err != nil {
|
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 {
|
func (self *Shell) NewBranch(name string) *Shell {
|
||||||
return s.RunCommand("git checkout -b " + name)
|
return self.RunCommand("git checkout -b " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) Checkout(name string) *Shell {
|
func (self *Shell) Checkout(name string) *Shell {
|
||||||
return s.RunCommand("git checkout " + name)
|
return self.RunCommand("git checkout " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) Merge(name string) *Shell {
|
func (self *Shell) Merge(name string) *Shell {
|
||||||
return s.RunCommand("git merge --commit --no-ff " + name)
|
return self.RunCommand("git merge --commit --no-ff " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) GitAdd(path string) *Shell {
|
func (self *Shell) GitAdd(path string) *Shell {
|
||||||
return s.RunCommand(fmt.Sprintf("git add \"%s\"", path))
|
return self.RunCommand(fmt.Sprintf("git add \"%s\"", path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) GitAddAll() *Shell {
|
func (self *Shell) GitAddAll() *Shell {
|
||||||
return s.RunCommand("git add -A")
|
return self.RunCommand("git add -A")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) Commit(message string) *Shell {
|
func (self *Shell) Commit(message string) *Shell {
|
||||||
return s.RunCommand(fmt.Sprintf("git commit -m \"%s\"", message))
|
return self.RunCommand(fmt.Sprintf("git commit -m \"%s\"", message))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) EmptyCommit(message string) *Shell {
|
func (self *Shell) EmptyCommit(message string) *Shell {
|
||||||
return s.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message))
|
return self.RunCommand(fmt.Sprintf("git commit --allow-empty -m \"%s\"", message))
|
||||||
}
|
}
|
||||||
|
|
||||||
// convenience method for creating a file and adding it
|
// convenience method for creating a file and adding it
|
||||||
func (s *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell {
|
func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell {
|
||||||
return s.
|
return self.
|
||||||
CreateFile(fileName, fileContents).
|
CreateFile(fileName, fileContents).
|
||||||
GitAdd(fileName)
|
GitAdd(fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convenience method for updating a file and adding it
|
// convenience method for updating a file and adding it
|
||||||
func (s *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell {
|
func (self *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell {
|
||||||
return s.
|
return self.
|
||||||
UpdateFile(fileName, fileContents).
|
UpdateFile(fileName, fileContents).
|
||||||
GitAdd(fileName)
|
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
|
// 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
|
// 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
|
// 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++ {
|
for i := 1; i <= n; i++ {
|
||||||
s.CreateFileAndAdd(
|
self.CreateFileAndAdd(
|
||||||
fmt.Sprintf("file%02d.txt", i),
|
fmt.Sprintf("file%02d.txt", i),
|
||||||
fmt.Sprintf("file%02d content", i),
|
fmt.Sprintf("file%02d content", i),
|
||||||
).
|
).
|
||||||
Commit(fmt.Sprintf("commit %02d", i))
|
Commit(fmt.Sprintf("commit %02d", i))
|
||||||
}
|
}
|
||||||
|
|
||||||
return s
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) StashWithMessage(message string) *Shell {
|
func (self *Shell) StashWithMessage(message string) *Shell {
|
||||||
s.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message))
|
self.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message))
|
||||||
return s
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Shell) SetConfig(key string, value string) *Shell {
|
func (self *Shell) SetConfig(key string, value string) *Shell {
|
||||||
s.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
|
self.RunCommand(fmt.Sprintf(`git config --local "%s" %s`, key, value))
|
||||||
return s
|
return self
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,7 @@ type IntegrationTest struct {
|
|||||||
setupRepo func(shell *Shell)
|
setupRepo func(shell *Shell)
|
||||||
setupConfig func(config *config.AppConfig)
|
setupConfig func(config *config.AppConfig)
|
||||||
run func(
|
run func(
|
||||||
shell *Shell,
|
testDriver *TestDriver,
|
||||||
testController *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
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
|
// takes a config and mutates. The mutated context will end up being passed to the gui
|
||||||
SetupConfig func(config *config.AppConfig)
|
SetupConfig func(config *config.AppConfig)
|
||||||
// runs the test
|
// runs the test
|
||||||
Run func(shell *Shell, t *TestDriver, keys config.KeybindingConfig)
|
Run func(t *TestDriver, keys config.KeybindingConfig)
|
||||||
// additional args passed to lazygit
|
// additional args passed to lazygit
|
||||||
ExtraCmdArgs string
|
ExtraCmdArgs string
|
||||||
// for when a test is flakey
|
// 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,
|
// 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) {
|
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()
|
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 {
|
if KeyPressDelay() > 0 {
|
||||||
// the dev would want to see the final state if they're running in slow mode
|
// the dev would want to see the final state if they're running in slow mode
|
||||||
testController.Wait(2000)
|
testDriver.Wait(2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,14 +16,16 @@ type TestDriver struct {
|
|||||||
keys config.KeybindingConfig
|
keys config.KeybindingConfig
|
||||||
pushKeyDelay int
|
pushKeyDelay int
|
||||||
*assertionHelper
|
*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{
|
return &TestDriver{
|
||||||
gui: gui,
|
gui: gui,
|
||||||
keys: keys,
|
keys: keys,
|
||||||
pushKeyDelay: pushKeyDelay,
|
pushKeyDelay: pushKeyDelay,
|
||||||
assertionHelper: &assertionHelper{gui: gui},
|
assertionHelper: &assertionHelper{gui: gui},
|
||||||
|
shell: shell,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +69,11 @@ func (self *TestDriver) Log(message string) {
|
|||||||
self.gui.LogUI(message)
|
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
|
// 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.
|
// enter the keypresses required to navigate to it.
|
||||||
// The test will fail if:
|
// The test will fail if:
|
||||||
|
@ -63,7 +63,7 @@ func (self *fakeGuiDriver) View(viewName string) *gocui.View {
|
|||||||
func TestAssertionFailure(t *testing.T) {
|
func TestAssertionFailure(t *testing.T) {
|
||||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Description: unitTestDescription,
|
Description: unitTestDescription,
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.press("a")
|
t.press("a")
|
||||||
t.press("b")
|
t.press("b")
|
||||||
t.Model().CommitCount(2)
|
t.Model().CommitCount(2)
|
||||||
@ -78,7 +78,7 @@ func TestAssertionFailure(t *testing.T) {
|
|||||||
func TestManualFailure(t *testing.T) {
|
func TestManualFailure(t *testing.T) {
|
||||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Description: unitTestDescription,
|
Description: unitTestDescription,
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Fail("blah")
|
t.Fail("blah")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -90,7 +90,7 @@ func TestManualFailure(t *testing.T) {
|
|||||||
func TestSuccess(t *testing.T) {
|
func TestSuccess(t *testing.T) {
|
||||||
test := NewIntegrationTest(NewIntegrationTestArgs{
|
test := NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
Description: unitTestDescription,
|
Description: unitTestDescription,
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.press("a")
|
t.press("a")
|
||||||
t.press("b")
|
t.press("b")
|
||||||
t.Model().CommitCount(0)
|
t.Model().CommitCount(0)
|
||||||
|
@ -14,11 +14,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateNCommits(10)
|
CreateNCommits(10)
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {},
|
SetupConfig: func(cfg *config.AppConfig) {},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
markCommitAsBad := func() {
|
markCommitAsBad := func() {
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
Press(keys.Commits.ViewBisectOptions)
|
Press(keys.Commits.ViewBisectOptions)
|
||||||
|
@ -18,11 +18,7 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
RunCommand("git bisect start other~2 other~5")
|
RunCommand("git bisect start other~2 other~5")
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {},
|
SetupConfig: func(cfg *config.AppConfig) {},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Views().Information().Content(Contains("bisecting"))
|
t.Views().Information().Content(Contains("bisecting"))
|
||||||
|
|
||||||
t.Model().AtLeastOneCommit()
|
t.Model().AtLeastOneCommit()
|
||||||
|
@ -17,7 +17,7 @@ var CheckoutByName = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Checkout("master").
|
Checkout("master").
|
||||||
EmptyCommit("blah")
|
EmptyCommit("blah")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -16,7 +16,7 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
NewBranch("branch-one").
|
NewBranch("branch-one").
|
||||||
NewBranch("branch-two")
|
NewBranch("branch-two")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -14,7 +14,7 @@ var Rebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shared.MergeConflictsSetup(shell)
|
shared.MergeConflictsSetup(shell)
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Commits().TopLines(
|
t.Views().Commits().TopLines(
|
||||||
Contains("first change"),
|
Contains("first change"),
|
||||||
Contains("original"),
|
Contains("original"),
|
||||||
|
@ -17,7 +17,7 @@ var RebaseAndDrop = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.EmptyCommit("to remove")
|
shell.EmptyCommit("to remove")
|
||||||
shell.EmptyCommit("to keep")
|
shell.EmptyCommit("to keep")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -20,7 +20,7 @@ var Reset = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.Checkout("current-branch")
|
shell.Checkout("current-branch")
|
||||||
shell.EmptyCommit("current-branch commit")
|
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(
|
t.Views().Commits().Lines(
|
||||||
Contains("current-branch commit"),
|
Contains("current-branch commit"),
|
||||||
Contains("root commit"),
|
Contains("root commit"),
|
||||||
|
@ -20,7 +20,7 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
NewBranch("other-new-branch-2").
|
NewBranch("other-new-branch-2").
|
||||||
NewBranch("other-new-branch-3")
|
NewBranch("other-new-branch-3")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Press(keys.Branches.CheckoutBranchByName)
|
Press(keys.Branches.CheckoutBranchByName)
|
||||||
|
@ -23,7 +23,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
EmptyCommit("four").
|
EmptyCommit("four").
|
||||||
Checkout("first-branch")
|
Checkout("first-branch")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -14,7 +14,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shared.MergeConflictsSetup(shell)
|
shared.MergeConflictsSetup(shell)
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -14,7 +14,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.CreateFile("myfile", "myfile content")
|
shell.CreateFile("myfile", "myfile content")
|
||||||
shell.CreateFile("myfile2", "myfile2 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.Model().CommitCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -13,7 +13,7 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.CreateFile("myfile", "myfile content")
|
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.Model().CommitCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -16,7 +16,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
EmptyCommit("commit 2").
|
EmptyCommit("commit 2").
|
||||||
EmptyCommit("commit 3")
|
EmptyCommit("commit 3")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Model().CommitCount(3)
|
t.Model().CommitCount(3)
|
||||||
|
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
|
@ -15,7 +15,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.GitAddAll()
|
shell.GitAddAll()
|
||||||
shell.Commit("first commit")
|
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.Model().CommitCount(1)
|
||||||
|
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
|
@ -15,7 +15,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateFile("myfile", "myfile content\nwith a second line").
|
CreateFile("myfile", "myfile content\nwith a second line").
|
||||||
CreateFile("myfile2", "myfile2 content")
|
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.Model().CommitCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -15,7 +15,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateFile("myfile", "myfile content\nwith a second line").
|
CreateFile("myfile", "myfile content\nwith a second line").
|
||||||
CreateFile("myfile2", "myfile2 content")
|
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.Model().CommitCount(0)
|
||||||
|
|
||||||
// stage the file
|
// stage the file
|
||||||
|
@ -17,7 +17,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateFile("myfile", "myfile content\nwith a second line").
|
CreateFile("myfile", "myfile content\nwith a second line").
|
||||||
CreateFile("myfile2", "myfile2 content")
|
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.Model().CommitCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -15,11 +15,7 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateNCommits(2)
|
CreateNCommits(2)
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {},
|
SetupConfig: func(cfg *config.AppConfig) {},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
// here we're just asserting that we haven't panicked upon starting lazygit
|
// here we're just asserting that we haven't panicked upon starting lazygit
|
||||||
t.Model().AtLeastOneCommit()
|
t.Model().AtLeastOneCommit()
|
||||||
},
|
},
|
||||||
|
@ -21,11 +21,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Model().WorkingTreeFileCount(0)
|
t.Model().WorkingTreeFileCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -55,11 +55,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Model().WorkingTreeFileCount(0)
|
t.Model().WorkingTreeFileCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -42,11 +42,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Model().WorkingTreeFileCount(0)
|
t.Model().WorkingTreeFileCount(0)
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
|
@ -41,11 +41,7 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Model().CurrentBranchName("feature/bar")
|
t.Model().CurrentBranchName("feature/bar")
|
||||||
t.Model().WorkingTreeFileCount(0)
|
t.Model().WorkingTreeFileCount(0)
|
||||||
|
|
||||||
|
@ -53,11 +53,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Run: func(
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
shell *Shell,
|
|
||||||
t *TestDriver,
|
|
||||||
keys config.KeybindingConfig,
|
|
||||||
) {
|
|
||||||
t.Model().WorkingTreeFileCount(0)
|
t.Model().WorkingTreeFileCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -21,7 +21,7 @@ var Diff = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
shell.Checkout("branch-a")
|
shell.Checkout("branch-a")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
TopLines(
|
TopLines(
|
||||||
|
@ -21,7 +21,7 @@ var DiffAndApplyPatch = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
|
|
||||||
shell.Checkout("branch-a")
|
shell.Checkout("branch-a")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Branches().
|
t.Views().Branches().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -18,7 +18,7 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
|
shell.UpdateFileAndAdd("file1", "first line\nsecond line\nthird line\n")
|
||||||
shell.Commit("third commit")
|
shell.Commit("third commit")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -21,7 +21,7 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.CreateFile("dir/untracked", "bar")
|
shell.CreateFile("dir/untracked", "bar")
|
||||||
shell.UpdateFile("dir/file", "baz")
|
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.Model().CommitCount(1)
|
||||||
|
|
||||||
t.Views().Main().
|
t.Views().Main().
|
||||||
|
@ -71,7 +71,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.RunShellCommand(`echo "renamed\nhaha" > renamed2.txt && git add renamed2.txt`)
|
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)
|
t.Model().CommitCount(3)
|
||||||
|
|
||||||
type statusFile struct {
|
type statusFile struct {
|
||||||
|
@ -27,7 +27,7 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Merge("feature-branch").
|
Merge("feature-branch").
|
||||||
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Model().CommitCount(3)
|
t.Model().CommitCount(3)
|
||||||
|
|
||||||
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
||||||
|
@ -14,7 +14,7 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.
|
shell.
|
||||||
CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01
|
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().
|
t.Views().Commits().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -13,7 +13,7 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
config.UserConfig.ConfirmOnQuit = true
|
config.UserConfig.ConfirmOnQuit = true
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {},
|
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.Model().CommitCount(0)
|
||||||
|
|
||||||
t.Views().Files().
|
t.Views().Files().
|
||||||
|
@ -18,7 +18,7 @@ var Rename = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateFileAndAdd("file-2", "change to stash2").
|
CreateFileAndAdd("file-2", "change to stash2").
|
||||||
StashWithMessage("bar")
|
StashWithMessage("bar")
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Stash().
|
t.Views().Stash().
|
||||||
Focus().
|
Focus().
|
||||||
Lines(
|
Lines(
|
||||||
|
@ -15,7 +15,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.CreateFile("file", "content")
|
shell.CreateFile("file", "content")
|
||||||
shell.GitAddAll()
|
shell.GitAddAll()
|
||||||
},
|
},
|
||||||
Run: func(shell *Shell, t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Model().StashCount(0)
|
t.Model().StashCount(0)
|
||||||
t.Model().WorkingTreeFileCount(1)
|
t.Model().WorkingTreeFileCount(1)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
shell.CreateFile("file_2", "content")
|
shell.CreateFile("file_2", "content")
|
||||||
shell.GitAdd("file_1")
|
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().StashCount(0)
|
||||||
t.Model().WorkingTreeFileCount(2)
|
t.Model().WorkingTreeFileCount(2)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user