mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-19 21:28:28 +02:00
tiny refactor
This commit is contained in:
parent
d7da6dde0e
commit
28ffaf9348
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user