diff --git a/integration/main.go b/integration/main.go index ace81b24d..9e9fc8751 100644 --- a/integration/main.go +++ b/integration/main.go @@ -21,13 +21,20 @@ import ( // as an env var. func main() { - err := test() + err := testWithEnvVars() if err != nil { panic(err) } } -func test() error { +func testWithEnvVars() error { + record := os.Getenv("RECORD_EVENTS") != "" + updateSnapshots := record || os.Getenv("UPDATE_SNAPSHOTS") != "" + + return test(record, updateSnapshots) +} + +func test(record bool, updateSnapshots bool) error { rootDir := integration.GetRootDirectory() err := os.Chdir(rootDir) if err != nil { @@ -47,10 +54,6 @@ func test() error { panic(err) } - record := os.Getenv("RECORD_EVENTS") != "" - - updateSnapshots := record || os.Getenv("UPDATE_SNAPSHOTS") != "" - selectedTestName := os.Args[1] for _, test := range tests { @@ -58,7 +61,8 @@ func test() error { continue } - speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots) + speedEnv := os.Getenv("SPEED") + speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots, speedEnv) testPath := filepath.Join(testDir, test.Name) actualDir := filepath.Join(testPath, "actual") expectedDir := filepath.Join(testPath, "expected") diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go index c6f945ae9..677b77f7c 100644 --- a/pkg/gui/gui_test.go +++ b/pkg/gui/gui_test.go @@ -57,7 +57,8 @@ func Test(t *testing.T) { test := test t.Run(test.Name, func(t *testing.T) { - speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots) + speedEnv := os.Getenv("SPEED") + speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots, speedEnv) testPath := filepath.Join(testDir, test.Name) actualDir := filepath.Join(testPath, "actual") expectedDir := filepath.Join(testPath, "expected") diff --git a/pkg/integration/integration.go b/pkg/integration/integration.go index e7e21bbd7..e433f1954 100644 --- a/pkg/integration/integration.go +++ b/pkg/integration/integration.go @@ -79,15 +79,14 @@ func TempLazygitPath() string { return filepath.Join("/tmp", "lazygit", "test_lazygit") } -func GetTestSpeeds(testStartSpeed float64, updateSnapshots bool) []float64 { +func GetTestSpeeds(testStartSpeed float64, updateSnapshots bool, speedStr string) []float64 { if updateSnapshots { // have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot return []float64{1.0} } - speedEnv := os.Getenv("SPEED") - if speedEnv != "" { - speed, err := strconv.ParseFloat(speedEnv, 64) + if speedStr != "" { + speed, err := strconv.ParseFloat(speedStr, 64) if err != nil { panic(err) }