mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
better namespacing for assertions
This commit is contained in:
parent
be30cbb375
commit
09e80e5f2a
@ -7,7 +7,7 @@ type AlertAsserter struct {
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *AlertAsserter) getViewAsserter() *ViewAsserter {
|
||||
func (self *AlertAsserter) getViewAsserter() *Views {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
)
|
||||
|
||||
@ -14,212 +8,30 @@ import (
|
||||
|
||||
type Assert struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
*assertionHelper
|
||||
}
|
||||
|
||||
func NewAssert(gui integrationTypes.GuiDriver) *Assert {
|
||||
return &Assert{gui: gui}
|
||||
}
|
||||
|
||||
func (self *Assert) WorkingTreeFileCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Files)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d changed working tree files, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) CommitCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d commits present, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) StashCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().StashEntries)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d stash entries, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) AtLeastOneCommit() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
return actualCount > 0, "Expected at least one commit present"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) HeadCommitMessage(matcher *matcher) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present"
|
||||
})
|
||||
|
||||
self.matchString(matcher, "Unexpected commit message.",
|
||||
func() string {
|
||||
return self.gui.Model().Commits[0].Name
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (self *Assert) CurrentWindowName(expectedWindowName string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CurrentContext().GetView().Name()
|
||||
return actual == expectedWindowName, fmt.Sprintf("Expected current window name to be '%s', but got '%s'", expectedWindowName, actual)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) CurrentBranchName(expectedViewName string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CheckedOutRef().Name
|
||||
return actual == expectedViewName, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expectedViewName, actual)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InListContext() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentContext := self.gui.CurrentContext()
|
||||
_, ok := currentContext.(types.IListContext)
|
||||
return ok, fmt.Sprintf("Expected current context to be a list context, but got %s", currentContext.GetKey())
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InPrompt() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && currentView.Editable, "Expected prompt popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InConfirm() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected confirmation popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InAlert() {
|
||||
// basically the same thing as a confirmation popup with the current implementation
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InCommitMessagePanel() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "commitMessage", "Expected commit message panel to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) InMenu() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return self.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) NotInPopup() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentViewName := self.gui.CurrentContext().GetView().Name()
|
||||
return currentViewName != "menu" && currentViewName != "confirmation" && currentViewName != "commitMessage", "Expected popup not to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) matchString(matcher *matcher, context string, getValue func() string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
value := getValue()
|
||||
return matcher.context(context).test(value)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Assert) assertWithRetries(test func() (bool, string)) {
|
||||
waitTimes := []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000}
|
||||
|
||||
var message string
|
||||
for _, waitTime := range waitTimes {
|
||||
time.Sleep(time.Duration(waitTime) * time.Millisecond)
|
||||
|
||||
var ok bool
|
||||
ok, message = test()
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
self.Fail(message)
|
||||
}
|
||||
|
||||
// for when you just want to fail the test yourself
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
// for making assertions on lazygit views
|
||||
func (self *Assert) Views() *ViewAsserterGetter {
|
||||
return &ViewAsserterGetter{
|
||||
assert: self,
|
||||
}
|
||||
return &ViewAsserterGetter{assert: self}
|
||||
}
|
||||
|
||||
type ViewAsserterGetter struct {
|
||||
assert *Assert
|
||||
// for making assertions on the lazygit model
|
||||
func (self *Assert) Model() *Model {
|
||||
return &Model{assertionHelper: self.assertionHelper, gui: self.gui}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Current() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "current view",
|
||||
getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
// for making assertions on the file system
|
||||
func (self *Assert) FileSystem() *FileSystem {
|
||||
return &FileSystem{assertionHelper: self.assertionHelper}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Main() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "main view",
|
||||
getView: func() *gocui.View { return self.assert.gui.MainView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Secondary() *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: "secondary view",
|
||||
getView: func() *gocui.View { return self.assert.gui.SecondaryView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) ByName(viewName string) *ViewAsserter {
|
||||
return &ViewAsserter{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.assert.gui.View(viewName) },
|
||||
assert: self.assert,
|
||||
}
|
||||
// for when you just want to fail the test yourself.
|
||||
// This runs callbacks to ensure we render the error after closing the gui.
|
||||
func (self *Assert) Fail(message string) {
|
||||
self.assertionHelper.fail(message)
|
||||
}
|
||||
|
40
pkg/integration/components/assertion_helper.go
Normal file
40
pkg/integration/components/assertion_helper.go
Normal file
@ -0,0 +1,40 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
)
|
||||
|
||||
type assertionHelper struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
}
|
||||
|
||||
// milliseconds we'll wait when an assertion fails.
|
||||
var retryWaitTimes = []int{0, 1, 1, 1, 1, 1, 5, 10, 20, 40, 100, 200, 500, 1000, 2000, 4000}
|
||||
|
||||
func (self *assertionHelper) matchString(matcher *matcher, context string, getValue func() string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
value := getValue()
|
||||
return matcher.context(context).test(value)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *assertionHelper) assertWithRetries(test func() (bool, string)) {
|
||||
var message string
|
||||
for _, waitTime := range retryWaitTimes {
|
||||
time.Sleep(time.Duration(waitTime) * time.Millisecond)
|
||||
|
||||
var ok bool
|
||||
ok, message = test()
|
||||
if ok {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
self.fail(message)
|
||||
}
|
||||
|
||||
func (self *assertionHelper) fail(message string) {
|
||||
self.gui.Fail(message)
|
||||
}
|
@ -5,7 +5,7 @@ type CommitMessagePanelAsserter struct {
|
||||
input *Input
|
||||
}
|
||||
|
||||
func (self *CommitMessagePanelAsserter) getViewAsserter() *ViewAsserter {
|
||||
func (self *CommitMessagePanelAsserter) getViewAsserter() *Views {
|
||||
return self.assert.Views().ByName("commitMessage")
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ type ConfirmationAsserter struct {
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *ConfirmationAsserter) getViewAsserter() *ViewAsserter {
|
||||
func (self *ConfirmationAsserter) getViewAsserter() *Views {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
|
26
pkg/integration/components/file_system.go
Normal file
26
pkg/integration/components/file_system.go
Normal file
@ -0,0 +1,26 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type FileSystem struct {
|
||||
*assertionHelper
|
||||
}
|
||||
|
||||
// This does _not_ check the files panel, it actually checks the filesystem
|
||||
func (self *FileSystem) PathPresent(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 *FileSystem) PathNotPresent(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)
|
||||
})
|
||||
}
|
@ -11,18 +11,20 @@ import (
|
||||
)
|
||||
|
||||
type Input struct {
|
||||
gui integrationTypes.GuiDriver
|
||||
keys config.KeybindingConfig
|
||||
assert *Assert
|
||||
gui integrationTypes.GuiDriver
|
||||
keys config.KeybindingConfig
|
||||
assert *Assert
|
||||
*assertionHelper
|
||||
pushKeyDelay int
|
||||
}
|
||||
|
||||
func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, assert *Assert, pushKeyDelay int) *Input {
|
||||
return &Input{
|
||||
gui: gui,
|
||||
keys: keys,
|
||||
assert: assert,
|
||||
pushKeyDelay: pushKeyDelay,
|
||||
gui: gui,
|
||||
keys: keys,
|
||||
assert: assert,
|
||||
pushKeyDelay: pushKeyDelay,
|
||||
assertionHelper: assert.assertionHelper,
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +44,7 @@ func (self *Input) press(keyStr string) {
|
||||
|
||||
func (self *Input) SwitchToStatusWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[0])
|
||||
self.assert.CurrentWindowName("status")
|
||||
self.currentWindowName("status")
|
||||
}
|
||||
|
||||
// switch to status window and assert that the status view is on top
|
||||
@ -53,7 +55,7 @@ func (self *Input) SwitchToStatusView() {
|
||||
|
||||
func (self *Input) SwitchToFilesWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[1])
|
||||
self.assert.CurrentWindowName("files")
|
||||
self.currentWindowName("files")
|
||||
}
|
||||
|
||||
// switch to files window and assert that the files view is on top
|
||||
@ -64,7 +66,7 @@ func (self *Input) SwitchToFilesView() {
|
||||
|
||||
func (self *Input) SwitchToBranchesWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[2])
|
||||
self.assert.CurrentWindowName("localBranches")
|
||||
self.currentWindowName("localBranches")
|
||||
}
|
||||
|
||||
// switch to branches window and assert that the branches view is on top
|
||||
@ -75,7 +77,7 @@ func (self *Input) SwitchToBranchesView() {
|
||||
|
||||
func (self *Input) SwitchToCommitsWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[3])
|
||||
self.assert.CurrentWindowName("commits")
|
||||
self.currentWindowName("commits")
|
||||
}
|
||||
|
||||
// switch to commits window and assert that the commits view is on top
|
||||
@ -86,7 +88,7 @@ func (self *Input) SwitchToCommitsView() {
|
||||
|
||||
func (self *Input) SwitchToStashWindow() {
|
||||
self.press(self.keys.Universal.JumpToBlock[4])
|
||||
self.assert.CurrentWindowName("stash")
|
||||
self.currentWindowName("stash")
|
||||
}
|
||||
|
||||
// switch to stash window and assert that the stash view is on top
|
||||
@ -166,7 +168,7 @@ func (self *Input) Log(message string) {
|
||||
// in the current page and failing that, jump to the top of the view and iterate through all of it,
|
||||
// looking for the item.
|
||||
func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
self.assert.InListContext()
|
||||
self.inListContext()
|
||||
|
||||
currentContext := self.gui.CurrentContext().(types.IListContext)
|
||||
|
||||
@ -215,32 +217,82 @@ func (self *Input) NavigateToListItem(matcher *matcher) {
|
||||
}
|
||||
}
|
||||
|
||||
func (self *Input) inListContext() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentContext := self.gui.CurrentContext()
|
||||
_, ok := currentContext.(types.IListContext)
|
||||
return ok, fmt.Sprintf("Expected current context to be a list context, but got %s", currentContext.GetKey())
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Confirmation() *ConfirmationAsserter {
|
||||
self.assert.InConfirm()
|
||||
self.inConfirm()
|
||||
|
||||
return &ConfirmationAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inConfirm() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected confirmation popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Prompt() *PromptAsserter {
|
||||
self.assert.InPrompt()
|
||||
self.inPrompt()
|
||||
|
||||
return &PromptAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inPrompt() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && currentView.Editable, "Expected prompt popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Alert() *AlertAsserter {
|
||||
self.assert.InAlert()
|
||||
self.inAlert()
|
||||
|
||||
return &AlertAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inAlert() {
|
||||
// basically the same thing as a confirmation popup with the current implementation
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) Menu() *MenuAsserter {
|
||||
self.assert.InMenu()
|
||||
self.inMenu()
|
||||
|
||||
return &MenuAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inMenu() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return self.gui.CurrentContext().GetView().Name() == "menu", "Expected popup menu to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) CommitMessagePanel() *CommitMessagePanelAsserter {
|
||||
self.assert.InCommitMessagePanel()
|
||||
self.inCommitMessagePanel()
|
||||
|
||||
return &CommitMessagePanelAsserter{assert: self.assert, input: self}
|
||||
}
|
||||
|
||||
func (self *Input) inCommitMessagePanel() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "commitMessage", "Expected commit message panel to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Input) currentWindowName(expectedWindowName string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CurrentContext().GetView().Name()
|
||||
return actual == expectedWindowName, fmt.Sprintf("Expected current window name to be '%s', but got '%s'", expectedWindowName, actual)
|
||||
})
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ type MenuAsserter struct {
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *MenuAsserter) getViewAsserter() *ViewAsserter {
|
||||
func (self *MenuAsserter) getViewAsserter() *Views {
|
||||
return self.assert.Views().ByName("menu")
|
||||
}
|
||||
|
||||
|
72
pkg/integration/components/model.go
Normal file
72
pkg/integration/components/model.go
Normal file
@ -0,0 +1,72 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
*assertionHelper
|
||||
gui integrationTypes.GuiDriver
|
||||
}
|
||||
|
||||
func (self *Model) WorkingTreeFileCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Files)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d changed working tree files, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Model) CommitCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d commits present, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Model) StashCount(expectedCount int) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().StashEntries)
|
||||
|
||||
return actualCount == expectedCount, fmt.Sprintf(
|
||||
"Expected %d stash entries, but got %d",
|
||||
expectedCount, actualCount,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Model) AtLeastOneCommit() {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actualCount := len(self.gui.Model().Commits)
|
||||
|
||||
return actualCount > 0, "Expected at least one commit present"
|
||||
})
|
||||
}
|
||||
|
||||
func (self *Model) HeadCommitMessage(matcher *matcher) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
return len(self.gui.Model().Commits) > 0, "Expected at least one commit to be present"
|
||||
})
|
||||
|
||||
self.matchString(matcher, "Unexpected commit message.",
|
||||
func() string {
|
||||
return self.gui.Model().Commits[0].Name
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (self *Model) CurrentBranchName(expectedViewName string) {
|
||||
self.assertWithRetries(func() (bool, string) {
|
||||
actual := self.gui.CheckedOutRef().Name
|
||||
return actual == expectedViewName, fmt.Sprintf("Expected current branch name to be '%s', but got '%s'", expectedViewName, actual)
|
||||
})
|
||||
}
|
@ -6,7 +6,7 @@ type PromptAsserter struct {
|
||||
hasCheckedTitle bool
|
||||
}
|
||||
|
||||
func (self *PromptAsserter) getViewAsserter() *ViewAsserter {
|
||||
func (self *PromptAsserter) getViewAsserter() *Views {
|
||||
return self.assert.Views().ByName("confirmation")
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ func TestAssertionFailure(t *testing.T) {
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.Press("a")
|
||||
input.Press("b")
|
||||
assert.CommitCount(2)
|
||||
assert.Model().CommitCount(2)
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
@ -93,7 +93,7 @@ func TestSuccess(t *testing.T) {
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
input.Press("a")
|
||||
input.Press("b")
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
},
|
||||
})
|
||||
driver := &fakeGuiDriver{}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
type ViewAsserter struct {
|
||||
type Views struct {
|
||||
// context is prepended to any error messages e.g. 'context: "current view"'
|
||||
context string
|
||||
getView func() *gocui.View
|
||||
@ -15,7 +15,7 @@ type ViewAsserter struct {
|
||||
|
||||
// asserts that the view has the expected name. This is typically used in tandem with the CurrentView method i.e.;
|
||||
// assert.CurrentView().Name("commits") to assert that the current view is the commits view.
|
||||
func (self *ViewAsserter) Name(expected string) *ViewAsserter {
|
||||
func (self *Views) Name(expected string) *Views {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Name()
|
||||
return actual == expected, fmt.Sprintf("%s: Expected view name to be '%s', but got '%s'", self.context, expected, actual)
|
||||
@ -25,7 +25,7 @@ func (self *ViewAsserter) Name(expected string) *ViewAsserter {
|
||||
}
|
||||
|
||||
// asserts that the view has the expected title
|
||||
func (self *ViewAsserter) Title(expected *matcher) *ViewAsserter {
|
||||
func (self *Views) Title(expected *matcher) *Views {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().Title
|
||||
return expected.context(fmt.Sprintf("%s title", self.context)).test(actual)
|
||||
@ -38,7 +38,7 @@ func (self *ViewAsserter) Title(expected *matcher) *ViewAsserter {
|
||||
// are passed, we only check the first three lines of the view.
|
||||
// This method is convenient when you have a list of commits but you only want to
|
||||
// assert on the first couple of commits.
|
||||
func (self *ViewAsserter) TopLines(matchers ...*matcher) *ViewAsserter {
|
||||
func (self *Views) TopLines(matchers ...*matcher) *Views {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) >= len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected at least %d, got %d", len(matchers), len(lines))
|
||||
@ -49,7 +49,7 @@ func (self *ViewAsserter) TopLines(matchers ...*matcher) *ViewAsserter {
|
||||
|
||||
// asserts that the view has lines matching the given matchers. One matcher must be passed for each line.
|
||||
// If you only care about the top n lines, use the TopLines method instead.
|
||||
func (self *ViewAsserter) Lines(matchers ...*matcher) *ViewAsserter {
|
||||
func (self *Views) Lines(matchers ...*matcher) *Views {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
lines := self.getView().BufferLines()
|
||||
return len(lines) == len(matchers), fmt.Sprintf("unexpected number of lines in view. Expected %d, got %d", len(matchers), len(lines))
|
||||
@ -58,7 +58,7 @@ func (self *ViewAsserter) Lines(matchers ...*matcher) *ViewAsserter {
|
||||
return self.assertLines(matchers...)
|
||||
}
|
||||
|
||||
func (self *ViewAsserter) assertLines(matchers ...*matcher) *ViewAsserter {
|
||||
func (self *Views) assertLines(matchers ...*matcher) *Views {
|
||||
view := self.getView()
|
||||
|
||||
for i, matcher := range matchers {
|
||||
@ -82,7 +82,7 @@ func (self *ViewAsserter) assertLines(matchers ...*matcher) *ViewAsserter {
|
||||
}
|
||||
|
||||
// asserts on the content of the view i.e. the stuff within the view's frame.
|
||||
func (self *ViewAsserter) Content(matcher *matcher) *ViewAsserter {
|
||||
func (self *Views) Content(matcher *matcher) *Views {
|
||||
self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context),
|
||||
func() string {
|
||||
return self.getView().Buffer()
|
||||
@ -93,7 +93,7 @@ func (self *ViewAsserter) Content(matcher *matcher) *ViewAsserter {
|
||||
}
|
||||
|
||||
// asserts on the selected line of the view
|
||||
func (self *ViewAsserter) SelectedLine(matcher *matcher) *ViewAsserter {
|
||||
func (self *Views) SelectedLine(matcher *matcher) *Views {
|
||||
self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context),
|
||||
func() string {
|
||||
return self.getView().SelectedLine()
|
||||
@ -104,7 +104,7 @@ func (self *ViewAsserter) SelectedLine(matcher *matcher) *ViewAsserter {
|
||||
}
|
||||
|
||||
// asserts on the index of the selected line. 0 is the first index, representing the line at the top of the view.
|
||||
func (self *ViewAsserter) SelectedLineIdx(expected int) *ViewAsserter {
|
||||
func (self *Views) SelectedLineIdx(expected int) *Views {
|
||||
self.assert.assertWithRetries(func() (bool, string) {
|
||||
actual := self.getView().SelectedLineIdx()
|
||||
return expected == actual, fmt.Sprintf("%s: Expected selected line index to be %d, got %d", self.context, expected, actual)
|
||||
@ -112,3 +112,39 @@ func (self *ViewAsserter) SelectedLineIdx(expected int) *ViewAsserter {
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
type ViewAsserterGetter struct {
|
||||
assert *Assert
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Current() *Views {
|
||||
return &Views{
|
||||
context: "current view",
|
||||
getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Main() *Views {
|
||||
return &Views{
|
||||
context: "main view",
|
||||
getView: func() *gocui.View { return self.assert.gui.MainView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) Secondary() *Views {
|
||||
return &Views{
|
||||
context: "secondary view",
|
||||
getView: func() *gocui.View { return self.assert.gui.SecondaryView() },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ViewAsserterGetter) ByName(viewName string) *Views {
|
||||
return &Views{
|
||||
context: fmt.Sprintf("%s view", viewName),
|
||||
getView: func() *gocui.View { return self.assert.gui.View(viewName) },
|
||||
assert: self.assert,
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
|
||||
}
|
||||
|
||||
assert.AtLeastOneCommit()
|
||||
assert.Model().AtLeastOneCommit()
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
|
@ -26,7 +26,7 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
) {
|
||||
assert.Views().ByName("information").Content(Contains("bisecting"))
|
||||
|
||||
assert.AtLeastOneCommit()
|
||||
assert.Model().AtLeastOneCommit()
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
|
@ -34,6 +34,6 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
SelectFirstSuggestion().
|
||||
Confirm()
|
||||
|
||||
assert.CurrentBranchName("branch-to-checkout")
|
||||
assert.Model().CurrentBranchName("branch-to-checkout")
|
||||
},
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Confirm()
|
||||
|
||||
assert.Views().Current().Name("files")
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
|
@ -15,7 +15,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
input.PrimaryAction()
|
||||
input.NextItem()
|
||||
@ -26,7 +26,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.CommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
assert.CommitCount(1)
|
||||
assert.HeadCommitMessage(Equals(commitMessage))
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
},
|
||||
})
|
||||
|
@ -14,15 +14,15 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.CreateFile("myfile", "myfile content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
input.PrimaryAction()
|
||||
input.Press(keys.Files.CommitChanges)
|
||||
|
||||
input.CommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
|
||||
|
||||
assert.CommitCount(1)
|
||||
assert.HeadCommitMessage(Equals("first line"))
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals("first line"))
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))
|
||||
|
@ -17,7 +17,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
EmptyCommit("commit 3")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(3)
|
||||
assert.Model().CommitCount(3)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
assert.Views().Current().Lines(
|
||||
@ -32,7 +32,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
branchName := "my-branch-name"
|
||||
input.Prompt().Title(Equals("New Branch Name")).Type(branchName).Confirm()
|
||||
|
||||
assert.CurrentBranchName(branchName)
|
||||
assert.Model().CurrentBranchName(branchName)
|
||||
|
||||
assert.Views().ByName("commits").Lines(
|
||||
Contains("commit 2"),
|
||||
|
@ -16,7 +16,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.Commit("first commit")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(1)
|
||||
assert.Model().CommitCount(1)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
@ -37,6 +37,6 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
)
|
||||
|
||||
assert.Views().Main().Content(Contains("-myfile content"))
|
||||
assert.FileSystemPathNotPresent("myfile")
|
||||
assert.FileSystem().PathNotPresent("myfile")
|
||||
},
|
||||
})
|
||||
|
@ -16,7 +16,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
assert.Views().Current().Name("files")
|
||||
assert.Views().Current().SelectedLine(Contains("myfile"))
|
||||
@ -44,9 +44,9 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Type(commitMessage)
|
||||
input.Confirm()
|
||||
|
||||
assert.CommitCount(1)
|
||||
assert.HeadCommitMessage(Equals(commitMessage))
|
||||
assert.CurrentWindowName("stagingSecondary")
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -16,7 +16,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
// stage the file
|
||||
assert.Views().Current().Name("files")
|
||||
@ -44,8 +44,8 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
commitMessage := ": my commit message"
|
||||
input.CommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
|
||||
|
||||
assert.CommitCount(1)
|
||||
assert.HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
|
||||
assert.Views().Current().Name("stagingSecondary")
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
|
@ -18,7 +18,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFile("myfile2", "myfile2 content")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
assert.Views().Current().Name("files").SelectedLine(Contains("myfile"))
|
||||
input.Enter()
|
||||
@ -34,9 +34,9 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
commitMessage := "my commit message"
|
||||
input.CommitMessagePanel().Type(commitMessage).Confirm()
|
||||
|
||||
assert.CommitCount(1)
|
||||
assert.HeadCommitMessage(Equals(commitMessage))
|
||||
assert.CurrentWindowName("staging")
|
||||
assert.Model().CommitCount(1)
|
||||
assert.Model().HeadCommitMessage(Equals(commitMessage))
|
||||
assert.Views().Current().Name("staging")
|
||||
|
||||
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
|
||||
},
|
||||
|
@ -22,6 +22,6 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
// here we're just asserting that we haven't panicked upon starting lazygit
|
||||
assert.AtLeastOneCommit()
|
||||
assert.Model().AtLeastOneCommit()
|
||||
},
|
||||
})
|
||||
|
@ -27,7 +27,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
|
||||
|
@ -61,7 +61,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
|
||||
@ -74,7 +74,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("my file"))
|
||||
assert.Views().Main().Content(Contains(`"BAR"`))
|
||||
},
|
||||
|
@ -48,7 +48,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.SwitchToBranchesView()
|
||||
|
||||
input.Press("a")
|
||||
@ -59,7 +59,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.SwitchToFilesView()
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("output.txt"))
|
||||
assert.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
|
||||
},
|
||||
|
@ -47,21 +47,20 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.CurrentBranchName("feature/bar")
|
||||
assert.Model().CurrentBranchName("feature/bar")
|
||||
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
input.SwitchToBranchesView()
|
||||
|
||||
input.Press("a")
|
||||
|
||||
assert.InPrompt()
|
||||
assert.Views().Current().
|
||||
input.Prompt().
|
||||
Title(Equals("Which git command do you want to run?")).
|
||||
SelectedLine(Equals("branch"))
|
||||
input.Confirm()
|
||||
InitialText(Equals("branch")).
|
||||
Confirm()
|
||||
|
||||
input.Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
|
||||
|
||||
assert.CurrentBranchName("master")
|
||||
assert.Model().CurrentBranchName("master")
|
||||
},
|
||||
})
|
||||
|
@ -59,7 +59,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
assert *Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
|
||||
input.Press("a")
|
||||
|
||||
@ -72,7 +72,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
|
||||
Confirm()
|
||||
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
assert.Views().Current().SelectedLine(Contains("myfile"))
|
||||
assert.Views().Main().Content(Contains("BAR"))
|
||||
},
|
||||
|
@ -30,8 +30,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
|
||||
|
||||
assert.NotInPopup()
|
||||
|
||||
assert.Views().ByName("information").Content(Contains("showing output for: git diff"))
|
||||
|
||||
input.NextItem()
|
||||
@ -42,7 +40,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.Press(keys.Universal.DiffingMenu)
|
||||
input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
|
||||
assert.NotInPopup()
|
||||
|
||||
assert.Views().Main().Content(Contains("+second line\n+third line"))
|
||||
|
||||
|
@ -22,7 +22,7 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.UpdateFile("dir/file", "baz")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(1)
|
||||
assert.Model().CommitCount(1)
|
||||
|
||||
assert.Views().Main().
|
||||
Content(DoesNotContain("error: Could not access")).
|
||||
|
@ -72,7 +72,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(3)
|
||||
assert.Model().CommitCount(3)
|
||||
|
||||
type statusFile struct {
|
||||
status string
|
||||
@ -118,6 +118,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
{status: "??", label: "new.txt", menuTitle: "new.txt"},
|
||||
})
|
||||
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -28,12 +28,12 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
CreateFileAndAdd(postMergeFilename, postMergeFileContent)
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(3)
|
||||
assert.Model().CommitCount(3)
|
||||
|
||||
input.SwitchToCommitsView()
|
||||
|
||||
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
|
||||
assert.HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
input.Press(keys.Commits.AmendToCommit)
|
||||
input.Confirmation().
|
||||
@ -42,8 +42,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Confirm()
|
||||
|
||||
// assuring we haven't added a brand new commit
|
||||
assert.CommitCount(3)
|
||||
assert.HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
assert.Model().CommitCount(3)
|
||||
assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
|
||||
|
||||
// assuring the post-merge file shows up in the merge commit.
|
||||
assert.Views().Main().
|
||||
|
@ -14,7 +14,7 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
},
|
||||
SetupRepo: func(shell *Shell) {},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.CommitCount(0)
|
||||
assert.Model().CommitCount(0)
|
||||
|
||||
input.Press(keys.Universal.Quit)
|
||||
input.Confirmation().
|
||||
|
@ -16,8 +16,8 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.GitAddAll()
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.StashCount(0)
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.Model().StashCount(0)
|
||||
assert.Model().WorkingTreeFileCount(1)
|
||||
|
||||
input.Press(keys.Files.ViewStashOptions)
|
||||
|
||||
@ -25,7 +25,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
assert.StashCount(1)
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().StashCount(1)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
@ -17,8 +17,8 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
shell.GitAdd("file_1")
|
||||
},
|
||||
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
|
||||
assert.StashCount(0)
|
||||
assert.WorkingTreeFileCount(2)
|
||||
assert.Model().StashCount(0)
|
||||
assert.Model().WorkingTreeFileCount(2)
|
||||
|
||||
input.Press(keys.Files.ViewStashOptions)
|
||||
|
||||
@ -26,7 +26,7 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
|
||||
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
|
||||
|
||||
assert.StashCount(1)
|
||||
assert.WorkingTreeFileCount(0)
|
||||
assert.Model().StashCount(1)
|
||||
assert.Model().WorkingTreeFileCount(0)
|
||||
},
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user