mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
tiny refactor
This commit is contained in:
parent
d7da6dde0e
commit
28ffaf9348
@ -21,13 +21,20 @@ import (
|
|||||||
// as an env var.
|
// as an env var.
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := test()
|
err := testWithEnvVars()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
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()
|
rootDir := integration.GetRootDirectory()
|
||||||
err := os.Chdir(rootDir)
|
err := os.Chdir(rootDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,10 +54,6 @@ func test() error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
record := os.Getenv("RECORD_EVENTS") != ""
|
|
||||||
|
|
||||||
updateSnapshots := record || os.Getenv("UPDATE_SNAPSHOTS") != ""
|
|
||||||
|
|
||||||
selectedTestName := os.Args[1]
|
selectedTestName := os.Args[1]
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
@ -58,7 +61,8 @@ func test() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots)
|
speedEnv := os.Getenv("SPEED")
|
||||||
|
speeds := integration.GetTestSpeeds(test.Speed, updateSnapshots, speedEnv)
|
||||||
testPath := filepath.Join(testDir, test.Name)
|
testPath := filepath.Join(testDir, test.Name)
|
||||||
actualDir := filepath.Join(testPath, "actual")
|
actualDir := filepath.Join(testPath, "actual")
|
||||||
expectedDir := filepath.Join(testPath, "expected")
|
expectedDir := filepath.Join(testPath, "expected")
|
||||||
|
@ -57,7 +57,8 @@ func Test(t *testing.T) {
|
|||||||
test := test
|
test := test
|
||||||
|
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
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)
|
testPath := filepath.Join(testDir, test.Name)
|
||||||
actualDir := filepath.Join(testPath, "actual")
|
actualDir := filepath.Join(testPath, "actual")
|
||||||
expectedDir := filepath.Join(testPath, "expected")
|
expectedDir := filepath.Join(testPath, "expected")
|
||||||
|
@ -79,15 +79,14 @@ func TempLazygitPath() string {
|
|||||||
return filepath.Join("/tmp", "lazygit", "test_lazygit")
|
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 {
|
if updateSnapshots {
|
||||||
// have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot
|
// have to go at original speed if updating snapshots in case we go to fast and create a junk snapshot
|
||||||
return []float64{1.0}
|
return []float64{1.0}
|
||||||
}
|
}
|
||||||
|
|
||||||
speedEnv := os.Getenv("SPEED")
|
if speedStr != "" {
|
||||||
if speedEnv != "" {
|
speed, err := strconv.ParseFloat(speedStr, 64)
|
||||||
speed, err := strconv.ParseFloat(speedEnv, 64)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user