1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-26 05:37:18 +02:00

67 lines
1.6 KiB
Go
Raw Normal View History

package oscommands
import (
2022-01-08 13:22:29 +11:00
"github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils"
)
// NewDummyOSCommand creates a new dummy OSCommand for testing
func NewDummyOSCommand() *OSCommand {
osCmd := NewOSCommand(utils.NewDummyCommon(), config.NewDummyAppConfig(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog()))
2022-01-03 15:15:26 +11:00
return osCmd
}
2021-12-30 13:11:58 +11:00
2022-01-08 13:22:29 +11:00
type OSCommandDeps struct {
Common *common.Common
Platform *Platform
GetenvFn func(string) string
RemoveFileFn func(string) error
Cmd *CmdObjBuilder
TempDir string
2022-01-08 13:22:29 +11:00
}
func NewDummyOSCommandWithDeps(deps OSCommandDeps) *OSCommand {
common := deps.Common
if common == nil {
common = utils.NewDummyCommon()
}
platform := deps.Platform
if platform == nil {
platform = dummyPlatform
}
return &OSCommand{
Common: common,
Platform: platform,
getenvFn: deps.GetenvFn,
removeFileFn: deps.RemoveFileFn,
guiIO: NewNullGuiIO(utils.NewDummyLog()),
tempDir: deps.TempDir,
2022-01-08 13:22:29 +11:00
}
}
2021-12-30 17:19:01 +11:00
func NewDummyCmdObjBuilder(runner ICmdObjRunner) *CmdObjBuilder {
2021-12-30 13:11:58 +11:00
return &CmdObjBuilder{
2022-01-05 12:01:59 +11:00
runner: runner,
platform: dummyPlatform,
2021-12-30 13:11:58 +11:00
}
}
2021-12-31 10:44:47 +11:00
2022-01-03 15:15:26 +11:00
var dummyPlatform = &Platform{
OS: "darwin",
Shell: "bash",
ShellArg: "-c",
OpenCommand: "open {{filename}}",
OpenLinkCommand: "open {{link}}",
}
2021-12-31 10:44:47 +11:00
func NewDummyOSCommandWithRunner(runner *FakeCmdObjRunner) *OSCommand {
osCommand := NewOSCommand(utils.NewDummyCommon(), config.NewDummyAppConfig(), dummyPlatform, NewNullGuiIO(utils.NewDummyLog()))
2021-12-31 10:44:47 +11:00
osCommand.Cmd = NewDummyCmdObjBuilder(runner)
return osCommand
}