mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-21 21:47:32 +02:00
fix test
This commit is contained in:
parent
08c2b46d04
commit
7a3291a1f7
@ -14,8 +14,9 @@ import (
|
|||||||
// this is the integration runner for the new and improved integration interface
|
// this is the integration runner for the new and improved integration interface
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TEST_NAME_ENV_VAR = "TEST_NAME"
|
TEST_NAME_ENV_VAR = "TEST_NAME"
|
||||||
SANDBOX_ENV_VAR = "SANDBOX"
|
SANDBOX_ENV_VAR = "SANDBOX"
|
||||||
|
GIT_CONFIG_GLOBAL_ENV_VAR = "GIT_CONFIG_GLOBAL"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunTests(
|
func RunTests(
|
||||||
@ -82,7 +83,7 @@ func runTest(
|
|||||||
|
|
||||||
logf("path: %s", paths.Root())
|
logf("path: %s", paths.Root())
|
||||||
|
|
||||||
if err := prepareTestDir(test, paths); err != nil {
|
if err := prepareTestDir(test, paths, projectRootDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +103,7 @@ func runTest(
|
|||||||
func prepareTestDir(
|
func prepareTestDir(
|
||||||
test *IntegrationTest,
|
test *IntegrationTest,
|
||||||
paths Paths,
|
paths Paths,
|
||||||
|
rootDir string,
|
||||||
) error {
|
) error {
|
||||||
findOrCreateDir(paths.Root())
|
findOrCreateDir(paths.Root())
|
||||||
deleteAndRecreateEmptyDir(paths.Actual())
|
deleteAndRecreateEmptyDir(paths.Actual())
|
||||||
@ -111,7 +113,7 @@ func prepareTestDir(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return createFixture(test, paths)
|
return createFixture(test, paths, rootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildLazygit() error {
|
func buildLazygit() error {
|
||||||
@ -125,28 +127,30 @@ func buildLazygit() error {
|
|||||||
)).Run()
|
)).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFixture(test *IntegrationTest, paths Paths) error {
|
func createFixture(test *IntegrationTest, paths Paths, rootDir string) error {
|
||||||
shell := NewShell(paths.ActualRepo(), func(errorMsg string) { panic(errorMsg) })
|
shell := NewShell(paths.ActualRepo(), func(errorMsg string) { panic(errorMsg) })
|
||||||
shell.RunCommand("git init -b master")
|
shell.RunCommand("git init -b master")
|
||||||
shell.RunCommand(`git config user.email "CI@example.com"`)
|
|
||||||
shell.RunCommand(`git config user.name "CI"`)
|
os.Setenv(GIT_CONFIG_GLOBAL_ENV_VAR, globalGitConfigPath(rootDir))
|
||||||
shell.RunCommand(`git config commit.gpgSign false`)
|
|
||||||
shell.RunCommand(`git config protocol.file.allow always`)
|
|
||||||
|
|
||||||
test.SetupRepo(shell)
|
test.SetupRepo(shell)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func globalGitConfigPath(rootDir string) string {
|
||||||
|
return filepath.Join(rootDir, "test", "global_git_config")
|
||||||
|
}
|
||||||
|
|
||||||
func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandbox bool, keyPressDelay int) (*exec.Cmd, error) {
|
func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandbox bool, keyPressDelay int) (*exec.Cmd, error) {
|
||||||
osCommand := oscommands.NewDummyOSCommand()
|
osCommand := oscommands.NewDummyOSCommand()
|
||||||
|
|
||||||
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
|
|
||||||
|
|
||||||
err := os.RemoveAll(paths.Config())
|
err := os.RemoveAll(paths.Config())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
|
||||||
err = oscommands.CopyDir(templateConfigDir, paths.Config())
|
err = oscommands.CopyDir(templateConfigDir, paths.Config())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -165,7 +169,7 @@ func getLazygitCommand(test *IntegrationTest, paths Paths, rootDir string, sandb
|
|||||||
cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay))
|
cmdObj.AddEnvVars(fmt.Sprintf("KEY_PRESS_DELAY=%d", keyPressDelay))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdObj.AddEnvVars("GIT_CONFIG_GLOBAL=/dev/null")
|
cmdObj.AddEnvVars(fmt.Sprintf("%s=%s", GIT_CONFIG_GLOBAL_ENV_VAR, globalGitConfigPath(rootDir)))
|
||||||
|
|
||||||
return cmdObj.GetCmd(), nil
|
return cmdObj.GetCmd(), nil
|
||||||
}
|
}
|
||||||
|
8
test/global_git_config
Normal file
8
test/global_git_config
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[user]
|
||||||
|
name = CI
|
||||||
|
email = CI@example.com
|
||||||
|
[protocol "file"]
|
||||||
|
# see https://vielmetti.typepad.com/logbook/2022/10/git-security-fixes-lead-to-fatal-transport-file-not-allowed-error-in-ci-systems-cve-2022-39253.html
|
||||||
|
allow = always
|
||||||
|
[commit]
|
||||||
|
gpgSign = false
|
Loading…
x
Reference in New Issue
Block a user