mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
add new integration test pattern
This commit is contained in:
parent
c7f9d5801b
commit
77881a9c7d
154 changed files with 1514 additions and 670 deletions
63
pkg/gui/test_mode.go
Normal file
63
pkg/gui/test_mode.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
package gui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
)
|
||||
|
||||
func (gui *Gui) handleTestMode() {
|
||||
if integration.PlayingIntegrationTest() {
|
||||
test, ok := integration.CurrentIntegrationTest()
|
||||
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("test %s not found", integration.IntegrationTestName()))
|
||||
}
|
||||
|
||||
go func() {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
|
||||
test.Run(
|
||||
&integration.ShellImpl{},
|
||||
&InputImpl{g: gui.g, keys: gui.Config.GetUserConfig().Keybinding},
|
||||
&AssertImpl{gui: gui},
|
||||
gui.c.UserConfig.Keybinding,
|
||||
)
|
||||
|
||||
gui.g.Update(func(*gocui.Gui) error {
|
||||
return gocui.ErrQuit
|
||||
})
|
||||
|
||||
time.Sleep(time.Second * 1)
|
||||
|
||||
log.Fatal("gocui should have already exited")
|
||||
}()
|
||||
|
||||
go utils.Safe(func() {
|
||||
time.Sleep(time.Second * 40)
|
||||
log.Fatal("40 seconds is up, lazygit recording took too long to complete")
|
||||
})
|
||||
}
|
||||
|
||||
if integration.Replaying() {
|
||||
gui.g.RecordingConfig = gocui.RecordingConfig{
|
||||
Speed: integration.GetRecordingSpeed(),
|
||||
Leeway: 100,
|
||||
}
|
||||
|
||||
var err error
|
||||
gui.g.Recording, err = integration.LoadRecording()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
go utils.Safe(func() {
|
||||
time.Sleep(time.Second * 40)
|
||||
log.Fatal("40 seconds is up, lazygit recording took too long to complete")
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue