mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
move code from main into app package to allow test to be injected
This commit is contained in:
parent
d890238c7b
commit
ba96baee32
68 changed files with 1096 additions and 482 deletions
22
main.go
22
main.go
|
@ -6,6 +6,8 @@ import (
|
|||
|
||||
"github.com/integrii/flaggy"
|
||||
"github.com/jesseduffield/lazygit/pkg/app"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
@ -24,8 +26,9 @@ var (
|
|||
func main() {
|
||||
cliArgs := parseCliArgsAndEnvVars()
|
||||
buildInfo := getBuildInfo()
|
||||
integrationTest := getIntegrationTest()
|
||||
|
||||
app.Start(cliArgs, buildInfo, nil)
|
||||
app.Start(cliArgs, buildInfo, integrationTest)
|
||||
}
|
||||
|
||||
func parseCliArgsAndEnvVars() *app.CliArgs {
|
||||
|
@ -129,3 +132,20 @@ func getBuildInfo() *app.BuildInfo {
|
|||
|
||||
return buildInfo
|
||||
}
|
||||
|
||||
func getIntegrationTest() integrationTypes.IntegrationTest {
|
||||
integrationTestName := os.Getenv("LAZYGIT_TEST_NAME")
|
||||
if integrationTestName == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// unsetting so that if we run lazygit in as a 'daemon' we don't think we're trying to run a test again
|
||||
os.Unsetenv("LAZYGIT_TEST_NAME")
|
||||
for _, candidateTest := range integration.Tests {
|
||||
if candidateTest.Name() == integrationTestName {
|
||||
return candidateTest
|
||||
}
|
||||
}
|
||||
|
||||
panic("Could not find integration test with name: " + integrationTestName)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue