jesseduffield.lazygit/pkg/integration/tests/custom_commands/basic_cmd_from_config.go
Stefan Haller c426df91f3 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.
2024-01-19 22:29:06 +01:00

40 lines
842 B
Go

package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var BasicCmdFromConfig = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command to create a new file",
ExtraCmdArgs: []string{},
Skip: false,
SetupRepo: func(shell *Shell) {
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: cmd,
},
}
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsEmpty().
IsFocused().
Press("a").
Lines(
Contains("myfile"),
)
},
})