summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-11-13 14:10:18 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-11-13 14:10:21 +1100
commitdf3cd941d7342a13df92e10f6726a1f1998ddf75 (patch)
treec97d97a8587fca92a1006acf4bd85cf4b950f0b6
parentea28529cbb4c462117c26de85254922d72365dda (diff)
use tempdir in tests to prevent polluting worktree
-rw-r--r--pkg/commands/git_commands/deps_test.go3
-rw-r--r--pkg/commands/oscommands/dummies.go2
2 files changed, 5 insertions, 0 deletions
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,
}
}