jesseduffield.lazygit/pkg/integration/tests/custom_commands/basic_cmd_at_runtime.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

42 lines
938 B
Go

package custom_commands
import (
"runtime"
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var BasicCmdAtRuntime = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Using a custom command provided at runtime to create a new file",
ExtraCmdArgs: []string{},
Skip: false,
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("blah")
},
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().
Press(keys.Universal.ExecuteCustomCommand)
t.ExpectPopup().Prompt().
Title(Equals("Custom command:")).
Type(cmd).
Confirm()
t.GlobalPress(keys.Files.RefreshFiles)
t.Views().Files().
IsFocused().
Lines(
Contains("file.txt"),
)
},
})