Skip to content

Commit

Permalink
use tempdir in tests to prevent polluting worktree
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Nov 13, 2022
1 parent ea28529 commit df3cd94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/commands/git_commands/deps_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -70,6 +72,7 @@ func buildGitCommon(deps commonDeps) *GitCommon {
GetenvFn: getenv,
Cmd: cmd,
RemoveFileFn: removeFile,
TempDir: os.TempDir(),
})

gitCommon.dotGitDir = deps.dotGitDir
Expand Down
2 changes: 2 additions & 0 deletions pkg/commands/oscommands/dummies.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type OSCommandDeps struct {
GetenvFn func(string) string
RemoveFileFn func(string) error
Cmd *CmdObjBuilder
TempDir string
}

func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand {
Expand All @@ -38,6 +39,7 @@ func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand {
getenvFn: deps.GetenvFn,
removeFileFn: deps.RemoveFileFn,
guiIO: NewNullGuiIO(utils.NewDummyLog()),
tempDir: deps.TempDir,
}
}

Expand Down

0 comments on commit df3cd94

Please sign in to comment.