2022-12-27 06:22:31 +02:00
|
|
|
package components
|
|
|
|
|
|
|
|
import (
|
|
|
|
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type assertionHelper struct {
|
|
|
|
gui integrationTypes.GuiDriver
|
|
|
|
}
|
|
|
|
|
2023-06-03 07:12:31 +02:00
|
|
|
func (self *assertionHelper) matchString(matcher *TextMatcher, context string, getValue func() string) {
|
2022-12-27 06:22:31 +02:00
|
|
|
self.assertWithRetries(func() (bool, string) {
|
|
|
|
value := getValue()
|
|
|
|
return matcher.context(context).test(value)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-07-08 07:23:58 +02:00
|
|
|
// 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.
|
2022-12-27 06:22:31 +02:00
|
|
|
func (self *assertionHelper) assertWithRetries(test func() (bool, string)) {
|
2023-07-08 07:23:58 +02:00
|
|
|
ok, message := test()
|
|
|
|
if !ok {
|
|
|
|
self.fail(message)
|
2022-12-27 06:22:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (self *assertionHelper) fail(message string) {
|
|
|
|
self.gui.Fail(message)
|
|
|
|
}
|