summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-09 21:27:12 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-13 13:55:08 +1000
commitba96baee32f5d02173312b357327eb7478492f89 (patch)
treefbd0c91d5799f9519d617f7041518c0c7e14d2bc /main.go
parentd890238c7bcbdd62e7158df0c1f3f0e5c0b05b66 (diff)
move code from main into app package to allow test to be injected
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/main.go b/main.go
index 8684b8cd6..6faf41ddf 100644
--- a/main.go
+++ b/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)
+}