mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
specify view when assertion on line count fails
This commit is contained in:
@@ -176,9 +176,11 @@ func (self *ViewDriver) validateMatchersPassed(matchers []*Matcher) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *ViewDriver) validateEnoughLines(matchers []*Matcher) {
|
func (self *ViewDriver) validateEnoughLines(matchers []*Matcher) {
|
||||||
|
view := self.getView()
|
||||||
|
|
||||||
self.t.assertWithRetries(func() (bool, string) {
|
self.t.assertWithRetries(func() (bool, string) {
|
||||||
lines := self.getView().BufferLines()
|
lines := view.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 '%s'. Expected at least %d, got %d", view.Name(), len(matchers), len(lines))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,21 +442,23 @@ func (self *ViewDriver) LineCount(expectedCount int) *ViewDriver {
|
|||||||
return self.IsEmpty()
|
return self.IsEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view := self.getView()
|
||||||
|
|
||||||
self.t.assertWithRetries(func() (bool, string) {
|
self.t.assertWithRetries(func() (bool, string) {
|
||||||
lines := self.getView().BufferLines()
|
lines := view.BufferLines()
|
||||||
return len(lines) == expectedCount, fmt.Sprintf("unexpected number of lines in view. Expected %d, got %d", expectedCount, len(lines))
|
return len(lines) == expectedCount, fmt.Sprintf("unexpected number of lines in view '%s'. Expected %d, got %d", view.Name(), expectedCount, len(lines))
|
||||||
})
|
})
|
||||||
|
|
||||||
self.t.assertWithRetries(func() (bool, string) {
|
self.t.assertWithRetries(func() (bool, string) {
|
||||||
lines := self.getView().BufferLines()
|
lines := view.BufferLines()
|
||||||
|
|
||||||
// if the view has a single blank line (often the case) we want to treat that as having no lines
|
// if the view has a single blank line (often the case) we want to treat that as having no lines
|
||||||
if len(lines) == 1 && expectedCount == 1 {
|
if len(lines) == 1 && expectedCount == 1 {
|
||||||
actual := strings.TrimSpace(self.getView().Buffer())
|
actual := strings.TrimSpace(view.Buffer())
|
||||||
return actual != "", "unexpected number of lines in view. Expected 1, got 0"
|
return actual != "", fmt.Sprintf("unexpected number of lines in view '%s'. Expected 1, got 0", view.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(lines) == expectedCount, fmt.Sprintf("unexpected number of lines in view. Expected %d, got %d", expectedCount, len(lines))
|
return len(lines) == expectedCount, fmt.Sprintf("unexpected number of lines in view '%s'. Expected %d, got %d", view.Name(), expectedCount, len(lines))
|
||||||
})
|
})
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|||||||
Reference in New Issue
Block a user