mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
c7a3b69eb9
I want to see how we go removing all retry logic within a test. Lazygit should be trusted to tell us when it's no longer busy, and if it that proves false we should fix the issue in the code rather than being lenient in the tests
30 lines
777 B
Go
30 lines
777 B
Go
package components
|
|
|
|
import (
|
|
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
|
)
|
|
|
|
type assertionHelper struct {
|
|
gui integrationTypes.GuiDriver
|
|
}
|
|
|
|
func (self *assertionHelper) matchString(matcher *TextMatcher, context string, getValue func() string) {
|
|
self.assertWithRetries(func() (bool, string) {
|
|
value := getValue()
|
|
return matcher.context(context).test(value)
|
|
})
|
|
}
|
|
|
|
// We no longer assert with retries now that lazygit tells us when it's no longer
|
|
// busy. But I'm keeping the function in case we want to re-introduce it later.
|
|
func (self *assertionHelper) assertWithRetries(test func() (bool, string)) {
|
|
ok, message := test()
|
|
if !ok {
|
|
self.fail(message)
|
|
}
|
|
}
|
|
|
|
func (self *assertionHelper) fail(message string) {
|
|
self.gui.Fail(message)
|
|
}
|