lazygit/pkg/integration/tests/commit/revert.go
2022-12-27 21:26:18 +11:00

42 lines
1.1 KiB
Go

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.Model().CommitCount(1)
input.SwitchToCommitsView()
assert.Views().Current().Lines(
Contains("first commit"),
)
input.Press(keys.Commits.RevertCommit)
input.Confirmation().
Title(Equals("Revert commit")).
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
Confirm()
assert.Views().Current().Name("commits").
Lines(
Contains("Revert \"first commit\"").IsSelected(),
Contains("first commit"),
)
assert.Views().Main().Content(Contains("-myfile content"))
assert.FileSystem().PathNotPresent("myfile")
},
})