mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
add commit revert integration test
This commit is contained in:
@@ -2,6 +2,7 @@ package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -259,3 +260,19 @@ func (self *Assert) assertWithRetries(test func() (bool, string)) {
|
||||
func (self *Assert) Fail(message string) {
|
||||
self.gui.Fail(message)
|
||||
}
|
||||
|
||||
// This does _not_ check the files panel, it actually checks the filesystem
|
||||
func (self *Assert) FileSystemPathPresent(path string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil, fmt.Sprintf("Expected path '%s' to exist, but it does not", path)
|
||||
})
|
||||
}
|
||||
|
||||
// This does _not_ check the files panel, it actually checks the filesystem
|
||||
func (self *Assert) FileSystemPathNotPresent(path string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
_, err := os.Stat(path)
|
||||
return os.IsNotExist(err), fmt.Sprintf("Expected path '%s' to not exist, but it does", path)
|
||||
})
|
||||
}
|
||||
|
||||
37
pkg/integration/tests/commit/revert.go
Normal file
37
pkg/integration/tests/commit/revert.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package commit
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Reverts a commit",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
shell.GitAddAll()
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(1)
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
|
||||
input.PressKeys(keys.Commits.RevertCommit)
|
||||
assert.InConfirm()
|
||||
assert.MatchCurrentViewTitle(Equals("Revert commit"))
|
||||
assert.MatchCurrentViewContent(MatchesRegexp("Are you sure you want to revert \\w+?"))
|
||||
input.Confirm()
|
||||
|
||||
assert.CommitCount(2)
|
||||
assert.MatchHeadCommitMessage(Contains("Revert \"first commit\""))
|
||||
input.PreviousItem()
|
||||
assert.MatchMainViewContent(Contains("-myfile content"))
|
||||
assert.FileSystemPathNotPresent("myfile")
|
||||
|
||||
input.Wait(10)
|
||||
},
|
||||
})
|
||||
@@ -37,6 +37,7 @@ var tests = []*components.IntegrationTest{
|
||||
cherry_pick.CherryPickConflicts,
|
||||
commit.Commit,
|
||||
commit.CommitMultiline,
|
||||
commit.Revert,
|
||||
commit.NewBranch,
|
||||
commit.Staged,
|
||||
commit.Unstaged,
|
||||
|
||||
Reference in New Issue
Block a user