1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

better namespacing for assertions

This commit is contained in:
Jesse Duffield
2022-12-27 15:22:31 +11:00
parent be30cbb375
commit 09e80e5f2a
36 changed files with 328 additions and 294 deletions

View File

@ -7,7 +7,7 @@ type AlertAsserter struct {
hasCheckedContent bool hasCheckedContent bool
} }
func (self *AlertAsserter) getViewAsserter() *ViewAsserter { func (self *AlertAsserter) getViewAsserter() *Views {
return self.assert.Views().ByName("confirmation") return self.assert.Views().ByName("confirmation")
} }

View File

@ -1,12 +1,6 @@
package components package components
import ( import (
"fmt"
"os"
"time"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/types"
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
) )
@ -14,212 +8,30 @@ import (
type Assert struct { type Assert struct {
gui integrationTypes.GuiDriver gui integrationTypes.GuiDriver
*assertionHelper
} }
func NewAssert(gui integrationTypes.GuiDriver) *Assert { func NewAssert(gui integrationTypes.GuiDriver) *Assert {
return &Assert{gui: gui} return &Assert{gui: gui}
} }
func (self *Assert) WorkingTreeFileCount(expectedCount int) { // for making assertions on lazygit views
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)
})
}
func (self *Assert) Views() *ViewAsserterGetter { func (self *Assert) Views() *ViewAsserterGetter {
return &ViewAsserterGetter{ return &ViewAsserterGetter{assert: self}
assert: self,
}
} }
type ViewAsserterGetter struct { // for making assertions on the lazygit model
assert *Assert func (self *Assert) Model() *Model {
return &Model{assertionHelper: self.assertionHelper, gui: self.gui}
} }
func (self *ViewAsserterGetter) Current() *ViewAsserter { // for making assertions on the file system
return &ViewAsserter{ func (self *Assert) FileSystem() *FileSystem {
context: "current view", return &FileSystem{assertionHelper: self.assertionHelper}
getView: func() *gocui.View { return self.assert.gui.CurrentContext().GetView() },
assert: self.assert,
}
} }
func (self *ViewAsserterGetter) Main() *ViewAsserter { // for when you just want to fail the test yourself.
return &ViewAsserter{ // This runs callbacks to ensure we render the error after closing the gui.
context: "main view", func (self *Assert) Fail(message string) {
getView: func() *gocui.View { return self.assert.gui.MainView() }, self.assertionHelper.fail(message)
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,
}
} }

View 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)
}

View File

@ -5,7 +5,7 @@ type CommitMessagePanelAsserter struct {
input *Input input *Input
} }
func (self *CommitMessagePanelAsserter) getViewAsserter() *ViewAsserter { func (self *CommitMessagePanelAsserter) getViewAsserter() *Views {
return self.assert.Views().ByName("commitMessage") return self.assert.Views().ByName("commitMessage")
} }

View File

@ -7,7 +7,7 @@ type ConfirmationAsserter struct {
hasCheckedContent bool hasCheckedContent bool
} }
func (self *ConfirmationAsserter) getViewAsserter() *ViewAsserter { func (self *ConfirmationAsserter) getViewAsserter() *Views {
return self.assert.Views().ByName("confirmation") return self.assert.Views().ByName("confirmation")
} }

View 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)
})
}

View File

@ -14,6 +14,7 @@ type Input struct {
gui integrationTypes.GuiDriver gui integrationTypes.GuiDriver
keys config.KeybindingConfig keys config.KeybindingConfig
assert *Assert assert *Assert
*assertionHelper
pushKeyDelay int pushKeyDelay int
} }
@ -23,6 +24,7 @@ func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, asse
keys: keys, keys: keys,
assert: assert, assert: assert,
pushKeyDelay: pushKeyDelay, pushKeyDelay: pushKeyDelay,
assertionHelper: assert.assertionHelper,
} }
} }
@ -42,7 +44,7 @@ func (self *Input) press(keyStr string) {
func (self *Input) SwitchToStatusWindow() { func (self *Input) SwitchToStatusWindow() {
self.press(self.keys.Universal.JumpToBlock[0]) 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 // 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() { func (self *Input) SwitchToFilesWindow() {
self.press(self.keys.Universal.JumpToBlock[1]) 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 // 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() { func (self *Input) SwitchToBranchesWindow() {
self.press(self.keys.Universal.JumpToBlock[2]) 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 // 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() { func (self *Input) SwitchToCommitsWindow() {
self.press(self.keys.Universal.JumpToBlock[3]) 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 // 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() { func (self *Input) SwitchToStashWindow() {
self.press(self.keys.Universal.JumpToBlock[4]) 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 // 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, // in the current page and failing that, jump to the top of the view and iterate through all of it,
// looking for the item. // looking for the item.
func (self *Input) NavigateToListItem(matcher *matcher) { func (self *Input) NavigateToListItem(matcher *matcher) {
self.assert.InListContext() self.inListContext()
currentContext := self.gui.CurrentContext().(types.IListContext) 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 { func (self *Input) Confirmation() *ConfirmationAsserter {
self.assert.InConfirm() self.inConfirm()
return &ConfirmationAsserter{assert: self.assert, input: self} 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 { func (self *Input) Prompt() *PromptAsserter {
self.assert.InPrompt() self.inPrompt()
return &PromptAsserter{assert: self.assert, input: self} 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 { func (self *Input) Alert() *AlertAsserter {
self.assert.InAlert() self.inAlert()
return &AlertAsserter{assert: self.assert, input: self} 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 { func (self *Input) Menu() *MenuAsserter {
self.assert.InMenu() self.inMenu()
return &MenuAsserter{assert: self.assert, input: self} 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 { func (self *Input) CommitMessagePanel() *CommitMessagePanelAsserter {
self.assert.InCommitMessagePanel() self.inCommitMessagePanel()
return &CommitMessagePanelAsserter{assert: self.assert, input: self} 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)
})
}

View File

@ -6,7 +6,7 @@ type MenuAsserter struct {
hasCheckedTitle bool hasCheckedTitle bool
} }
func (self *MenuAsserter) getViewAsserter() *ViewAsserter { func (self *MenuAsserter) getViewAsserter() *Views {
return self.assert.Views().ByName("menu") return self.assert.Views().ByName("menu")
} }

View 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)
})
}

View File

@ -6,7 +6,7 @@ type PromptAsserter struct {
hasCheckedTitle bool hasCheckedTitle bool
} }
func (self *PromptAsserter) getViewAsserter() *ViewAsserter { func (self *PromptAsserter) getViewAsserter() *Views {
return self.assert.Views().ByName("confirmation") return self.assert.Views().ByName("confirmation")
} }

View File

@ -66,7 +66,7 @@ func TestAssertionFailure(t *testing.T) {
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
input.Press("a") input.Press("a")
input.Press("b") input.Press("b")
assert.CommitCount(2) assert.Model().CommitCount(2)
}, },
}) })
driver := &fakeGuiDriver{} driver := &fakeGuiDriver{}
@ -93,7 +93,7 @@ func TestSuccess(t *testing.T) {
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
input.Press("a") input.Press("a")
input.Press("b") input.Press("b")
assert.CommitCount(0) assert.Model().CommitCount(0)
}, },
}) })
driver := &fakeGuiDriver{} driver := &fakeGuiDriver{}

View File

@ -6,7 +6,7 @@ import (
"github.com/jesseduffield/gocui" "github.com/jesseduffield/gocui"
) )
type ViewAsserter struct { type Views struct {
// context is prepended to any error messages e.g. 'context: "current view"' // context is prepended to any error messages e.g. 'context: "current view"'
context string context string
getView func() *gocui.View 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.; // 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. // 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) { self.assert.assertWithRetries(func() (bool, string) {
actual := self.getView().Name() actual := self.getView().Name()
return actual == expected, fmt.Sprintf("%s: Expected view name to be '%s', but got '%s'", self.context, expected, actual) 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 // 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) { self.assert.assertWithRetries(func() (bool, string) {
actual := self.getView().Title actual := self.getView().Title
return expected.context(fmt.Sprintf("%s title", self.context)).test(actual) 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. // 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 // This method is convenient when you have a list of commits but you only want to
// assert on the first couple of commits. // 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) { self.assert.assertWithRetries(func() (bool, string) {
lines := self.getView().BufferLines() 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)) 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. // 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. // 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) { self.assert.assertWithRetries(func() (bool, string) {
lines := self.getView().BufferLines() 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)) 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...) return self.assertLines(matchers...)
} }
func (self *ViewAsserter) assertLines(matchers ...*matcher) *ViewAsserter { func (self *Views) assertLines(matchers ...*matcher) *Views {
view := self.getView() view := self.getView()
for i, matcher := range matchers { 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. // 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), self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected content.", self.context),
func() string { func() string {
return self.getView().Buffer() return self.getView().Buffer()
@ -93,7 +93,7 @@ func (self *ViewAsserter) Content(matcher *matcher) *ViewAsserter {
} }
// asserts on the selected line of the view // 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), self.assert.matchString(matcher, fmt.Sprintf("%s: Unexpected selected line.", self.context),
func() string { func() string {
return self.getView().SelectedLine() 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. // 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) { self.assert.assertWithRetries(func() (bool, string) {
actual := self.getView().SelectedLineIdx() actual := self.getView().SelectedLineIdx()
return expected == actual, fmt.Sprintf("%s: Expected selected line index to be %d, got %d", self.context, expected, actual) 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 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,
}
}

View File

@ -30,7 +30,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm() input.Menu().Title(Equals("Bisect")).Select(MatchesRegexp(`mark .* as good`)).Confirm()
} }
assert.AtLeastOneCommit() assert.Model().AtLeastOneCommit()
input.SwitchToCommitsView() input.SwitchToCommitsView()

View File

@ -26,7 +26,7 @@ var FromOtherBranch = NewIntegrationTest(NewIntegrationTestArgs{
) { ) {
assert.Views().ByName("information").Content(Contains("bisecting")) assert.Views().ByName("information").Content(Contains("bisecting"))
assert.AtLeastOneCommit() assert.Model().AtLeastOneCommit()
input.SwitchToCommitsView() input.SwitchToCommitsView()

View File

@ -34,6 +34,6 @@ var Suggestions = NewIntegrationTest(NewIntegrationTestArgs{
SelectFirstSuggestion(). SelectFirstSuggestion().
Confirm() Confirm()
assert.CurrentBranchName("branch-to-checkout") assert.Model().CurrentBranchName("branch-to-checkout")
}, },
}) })

View File

@ -70,7 +70,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
Confirm() Confirm()
assert.Views().Current().Name("files") assert.Views().Current().Name("files")
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.SwitchToCommitsView() input.SwitchToCommitsView()

View File

@ -15,7 +15,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("myfile2", "myfile2 content") shell.CreateFile("myfile2", "myfile2 content")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0) assert.Model().CommitCount(0)
input.PrimaryAction() input.PrimaryAction()
input.NextItem() input.NextItem()
@ -26,7 +26,7 @@ var Commit = NewIntegrationTest(NewIntegrationTestArgs{
input.CommitMessagePanel().Type(commitMessage).Confirm() input.CommitMessagePanel().Type(commitMessage).Confirm()
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.HeadCommitMessage(Equals(commitMessage)) assert.Model().HeadCommitMessage(Equals(commitMessage))
}, },
}) })

View File

@ -14,15 +14,15 @@ var CommitMultiline = NewIntegrationTest(NewIntegrationTestArgs{
shell.CreateFile("myfile", "myfile content") shell.CreateFile("myfile", "myfile content")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0) assert.Model().CommitCount(0)
input.PrimaryAction() input.PrimaryAction()
input.Press(keys.Files.CommitChanges) input.Press(keys.Files.CommitChanges)
input.CommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm() input.CommitMessagePanel().Type("first line").AddNewline().AddNewline().Type("third line").Confirm()
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.HeadCommitMessage(Equals("first line")) assert.Model().HeadCommitMessage(Equals("first line"))
input.SwitchToCommitsView() input.SwitchToCommitsView()
assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line")) assert.Views().Main().Content(MatchesRegexp("first line\n\\s*\n\\s*third line"))

View File

@ -17,7 +17,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
EmptyCommit("commit 3") EmptyCommit("commit 3")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(3) assert.Model().CommitCount(3)
input.SwitchToCommitsView() input.SwitchToCommitsView()
assert.Views().Current().Lines( assert.Views().Current().Lines(
@ -32,7 +32,7 @@ var NewBranch = NewIntegrationTest(NewIntegrationTestArgs{
branchName := "my-branch-name" branchName := "my-branch-name"
input.Prompt().Title(Equals("New Branch Name")).Type(branchName).Confirm() input.Prompt().Title(Equals("New Branch Name")).Type(branchName).Confirm()
assert.CurrentBranchName(branchName) assert.Model().CurrentBranchName(branchName)
assert.Views().ByName("commits").Lines( assert.Views().ByName("commits").Lines(
Contains("commit 2"), Contains("commit 2"),

View File

@ -16,7 +16,7 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
shell.Commit("first commit") shell.Commit("first commit")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(1) assert.Model().CommitCount(1)
input.SwitchToCommitsView() input.SwitchToCommitsView()
@ -37,6 +37,6 @@ var Revert = NewIntegrationTest(NewIntegrationTestArgs{
) )
assert.Views().Main().Content(Contains("-myfile content")) assert.Views().Main().Content(Contains("-myfile content"))
assert.FileSystemPathNotPresent("myfile") assert.FileSystem().PathNotPresent("myfile")
}, },
}) })

View File

@ -16,7 +16,7 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content") CreateFile("myfile2", "myfile2 content")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { 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().Name("files")
assert.Views().Current().SelectedLine(Contains("myfile")) assert.Views().Current().SelectedLine(Contains("myfile"))
@ -44,9 +44,9 @@ var Staged = NewIntegrationTest(NewIntegrationTestArgs{
input.Type(commitMessage) input.Type(commitMessage)
input.Confirm() input.Confirm()
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.HeadCommitMessage(Equals(commitMessage)) assert.Model().HeadCommitMessage(Equals(commitMessage))
assert.CurrentWindowName("stagingSecondary") assert.Views().Current().Name("stagingSecondary")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
}, },

View File

@ -16,7 +16,7 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content") CreateFile("myfile2", "myfile2 content")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0) assert.Model().CommitCount(0)
// stage the file // stage the file
assert.Views().Current().Name("files") assert.Views().Current().Name("files")
@ -44,8 +44,8 @@ var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{
commitMessage := ": my commit message" commitMessage := ": my commit message"
input.CommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm() input.CommitMessagePanel().InitialText(Contains("WIP")).Type(commitMessage).Confirm()
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.HeadCommitMessage(Equals("WIP" + commitMessage)) assert.Model().HeadCommitMessage(Equals("WIP" + commitMessage))
assert.Views().Current().Name("stagingSecondary") assert.Views().Current().Name("stagingSecondary")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)

View File

@ -18,7 +18,7 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
CreateFile("myfile2", "myfile2 content") CreateFile("myfile2", "myfile2 content")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { 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")) assert.Views().Current().Name("files").SelectedLine(Contains("myfile"))
input.Enter() input.Enter()
@ -34,9 +34,9 @@ var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{
commitMessage := "my commit message" commitMessage := "my commit message"
input.CommitMessagePanel().Type(commitMessage).Confirm() input.CommitMessagePanel().Type(commitMessage).Confirm()
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.HeadCommitMessage(Equals(commitMessage)) assert.Model().HeadCommitMessage(Equals(commitMessage))
assert.CurrentWindowName("staging") assert.Views().Current().Name("staging")
// TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed) // TODO: assert that the staging panel has been refreshed (it currently does not get correctly refreshed)
}, },

View File

@ -22,6 +22,6 @@ var RemoteNamedStar = NewIntegrationTest(NewIntegrationTestArgs{
keys config.KeybindingConfig, 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
assert.AtLeastOneCommit() assert.Model().AtLeastOneCommit()
}, },
}) })

View File

@ -27,7 +27,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert, assert *Assert,
keys config.KeybindingConfig, keys config.KeybindingConfig,
) { ) {
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.Press("a") input.Press("a")

View File

@ -61,7 +61,7 @@ var FormPrompts = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert, assert *Assert,
keys config.KeybindingConfig, keys config.KeybindingConfig,
) { ) {
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.Press("a") 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.")). Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
Confirm() Confirm()
assert.WorkingTreeFileCount(1) assert.Model().WorkingTreeFileCount(1)
assert.Views().Current().SelectedLine(Contains("my file")) assert.Views().Current().SelectedLine(Contains("my file"))
assert.Views().Main().Content(Contains(`"BAR"`)) assert.Views().Main().Content(Contains(`"BAR"`))
}, },

View File

@ -48,7 +48,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert, assert *Assert,
keys config.KeybindingConfig, keys config.KeybindingConfig,
) { ) {
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.SwitchToBranchesView() input.SwitchToBranchesView()
input.Press("a") input.Press("a")
@ -59,7 +59,7 @@ var MenuFromCommand = NewIntegrationTest(NewIntegrationTestArgs{
input.SwitchToFilesView() input.SwitchToFilesView()
assert.WorkingTreeFileCount(1) assert.Model().WorkingTreeFileCount(1)
assert.Views().Current().SelectedLine(Contains("output.txt")) assert.Views().Current().SelectedLine(Contains("output.txt"))
assert.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo")) assert.Views().Main().Content(Contains("bar Branch: #feature/foo my branch feature/foo"))
}, },

View File

@ -47,21 +47,20 @@ var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert, assert *Assert,
keys config.KeybindingConfig, keys config.KeybindingConfig,
) { ) {
assert.CurrentBranchName("feature/bar") assert.Model().CurrentBranchName("feature/bar")
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.SwitchToBranchesView() input.SwitchToBranchesView()
input.Press("a") input.Press("a")
assert.InPrompt() input.Prompt().
assert.Views().Current().
Title(Equals("Which git command do you want to run?")). Title(Equals("Which git command do you want to run?")).
SelectedLine(Equals("branch")) InitialText(Equals("branch")).
input.Confirm() Confirm()
input.Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm() input.Menu().Title(Equals("Branch:")).Select(Equals("master")).Confirm()
assert.CurrentBranchName("master") assert.Model().CurrentBranchName("master")
}, },
}) })

View File

@ -59,7 +59,7 @@ var MultiplePrompts = NewIntegrationTest(NewIntegrationTestArgs{
assert *Assert, assert *Assert,
keys config.KeybindingConfig, keys config.KeybindingConfig,
) { ) {
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
input.Press("a") 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.")). Content(Equals("Are you REALLY sure you want to make this file? Up to you buddy.")).
Confirm() Confirm()
assert.WorkingTreeFileCount(1) assert.Model().WorkingTreeFileCount(1)
assert.Views().Current().SelectedLine(Contains("myfile")) assert.Views().Current().SelectedLine(Contains("myfile"))
assert.Views().Main().Content(Contains("BAR")) assert.Views().Main().Content(Contains("BAR"))
}, },

View File

@ -30,8 +30,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
input.Press(keys.Universal.DiffingMenu) input.Press(keys.Universal.DiffingMenu)
input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm() input.Menu().Title(Equals("Diffing")).Select(MatchesRegexp(`diff \w+`)).Confirm()
assert.NotInPopup()
assert.Views().ByName("information").Content(Contains("showing output for: git diff")) assert.Views().ByName("information").Content(Contains("showing output for: git diff"))
input.NextItem() input.NextItem()
@ -42,7 +40,6 @@ var DiffCommits = NewIntegrationTest(NewIntegrationTestArgs{
input.Press(keys.Universal.DiffingMenu) input.Press(keys.Universal.DiffingMenu)
input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm() input.Menu().Title(Equals("Diffing")).Select(Contains("reverse diff direction")).Confirm()
assert.NotInPopup()
assert.Views().Main().Content(Contains("+second line\n+third line")) assert.Views().Main().Content(Contains("+second line\n+third line"))

View File

@ -22,7 +22,7 @@ var DirWithUntrackedFile = NewIntegrationTest(NewIntegrationTestArgs{
shell.UpdateFile("dir/file", "baz") shell.UpdateFile("dir/file", "baz")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(1) assert.Model().CommitCount(1)
assert.Views().Main(). assert.Views().Main().
Content(DoesNotContain("error: Could not access")). Content(DoesNotContain("error: Could not access")).

View File

@ -72,7 +72,7 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(3) assert.Model().CommitCount(3)
type statusFile struct { type statusFile struct {
status string status string
@ -118,6 +118,6 @@ var DiscardChanges = NewIntegrationTest(NewIntegrationTestArgs{
{status: "??", label: "new.txt", menuTitle: "new.txt"}, {status: "??", label: "new.txt", menuTitle: "new.txt"},
}) })
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
}, },
}) })

View File

@ -28,12 +28,12 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
CreateFileAndAdd(postMergeFilename, postMergeFileContent) CreateFileAndAdd(postMergeFilename, postMergeFileContent)
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(3) assert.Model().CommitCount(3)
input.SwitchToCommitsView() input.SwitchToCommitsView()
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch" mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
assert.HeadCommitMessage(Contains(mergeCommitMessage)) assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
input.Press(keys.Commits.AmendToCommit) input.Press(keys.Commits.AmendToCommit)
input.Confirmation(). input.Confirmation().
@ -42,8 +42,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
Confirm() Confirm()
// assuring we haven't added a brand new commit // assuring we haven't added a brand new commit
assert.CommitCount(3) assert.Model().CommitCount(3)
assert.HeadCommitMessage(Contains(mergeCommitMessage)) assert.Model().HeadCommitMessage(Contains(mergeCommitMessage))
// assuring the post-merge file shows up in the merge commit. // assuring the post-merge file shows up in the merge commit.
assert.Views().Main(). assert.Views().Main().

View File

@ -14,7 +14,7 @@ var ConfirmOnQuit = NewIntegrationTest(NewIntegrationTestArgs{
}, },
SetupRepo: func(shell *Shell) {}, SetupRepo: func(shell *Shell) {},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.CommitCount(0) assert.Model().CommitCount(0)
input.Press(keys.Universal.Quit) input.Press(keys.Universal.Quit)
input.Confirmation(). input.Confirmation().

View File

@ -16,8 +16,8 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
shell.GitAddAll() shell.GitAddAll()
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.StashCount(0) assert.Model().StashCount(0)
assert.WorkingTreeFileCount(1) assert.Model().WorkingTreeFileCount(1)
input.Press(keys.Files.ViewStashOptions) input.Press(keys.Files.ViewStashOptions)
@ -25,7 +25,7 @@ var Stash = NewIntegrationTest(NewIntegrationTestArgs{
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
assert.StashCount(1) assert.Model().StashCount(1)
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
}, },
}) })

View File

@ -17,8 +17,8 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
shell.GitAdd("file_1") shell.GitAdd("file_1")
}, },
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
assert.StashCount(0) assert.Model().StashCount(0)
assert.WorkingTreeFileCount(2) assert.Model().WorkingTreeFileCount(2)
input.Press(keys.Files.ViewStashOptions) input.Press(keys.Files.ViewStashOptions)
@ -26,7 +26,7 @@ var StashIncludingUntrackedFiles = NewIntegrationTest(NewIntegrationTestArgs{
input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() input.Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm()
assert.StashCount(1) assert.Model().StashCount(1)
assert.WorkingTreeFileCount(0) assert.Model().WorkingTreeFileCount(0)
}, },
}) })