Adapt tests for custom commands to work on Windows

The "touch" command isn't available on Windows, but "copy NUL file" seems to be
a good approximation.
This commit is contained in:
Stefan Haller 2024-01-19 22:12:47 +01:00
parent 7274d86d54
commit c426df91f3
2 changed files with 14 additions and 2 deletions

View file

@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@ -14,6 +16,10 @@ var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
},
SetupConfig: func(cfg *config.AppConfig) {},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
cmd := "touch file.txt"
if runtime.GOOS == "windows" {
cmd = "copy NUL file.txt"
}
t.Views().Files().
IsEmpty().
IsFocused().
@ -21,7 +27,7 @@ var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Prompt().
Title(Equals("Custom command:")).
Type("touch file.txt").
Type(cmd).
Confirm()
t.GlobalPress(keys.Files.RefreshFiles)

View file

@ -1,6 +1,8 @@
package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
@ -13,11 +15,15 @@ var BasicCmdFromConfig = NewIntegrationTest(NewIntegrationTestArgs{
shell.EmptyCommit("blah")
},
SetupConfig: func(cfg *config.AppConfig) {
cmd := "touch myfile"
if runtime.GOOS == "windows" {
cmd = "copy NUL myfile"
}
cfg.UserConfig.CustomCommands = []config.CustomCommand{
{
Key: "a",
Context: "files",
Command: "touch myfile",
Command: cmd,
},
}
},