From df3cd941d7342a13df92e10f6726a1f1998ddf75 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 13 Nov 2022 14:10:18 +1100 Subject: [PATCH] use tempdir in tests to prevent polluting worktree --- pkg/commands/git_commands/deps_test.go | 3 +++ pkg/commands/oscommands/dummies.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/pkg/commands/git_commands/deps_test.go b/pkg/commands/git_commands/deps_test.go index 834d51b55..535ba2712 100644 --- a/pkg/commands/git_commands/deps_test.go +++ b/pkg/commands/git_commands/deps_test.go @@ -1,6 +1,8 @@ package git_commands import ( + "os" + "github.com/go-errors/errors" gogit "github.com/jesseduffield/go-git/v5" "github.com/jesseduffield/lazygit/pkg/commands/git_config" @@ -70,6 +72,7 @@ func buildGitCommon(deps commonDeps) *GitCommon { GetenvFn: getenv, Cmd: cmd, RemoveFileFn: removeFile, + TempDir: os.TempDir(), }) gitCommon.dotGitDir = deps.dotGitDir diff --git a/pkg/commands/oscommands/dummies.go b/pkg/commands/oscommands/dummies.go index b5978e4b5..3f72a6f06 100644 --- a/pkg/commands/oscommands/dummies.go +++ b/pkg/commands/oscommands/dummies.go @@ -19,6 +19,7 @@ type OSCommandDeps struct { GetenvFn func(string) string RemoveFileFn func(string) error Cmd *CmdObjBuilder + TempDir string } func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand { @@ -38,6 +39,7 @@ func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand { getenvFn: deps.GetenvFn, removeFileFn: deps.RemoveFileFn, guiIO: NewNullGuiIO(utils.NewDummyLog()), + tempDir: deps.TempDir, } }