mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-25 18:55:28 -06:00
basic custom command test
This commit is contained in:
@@ -314,7 +314,9 @@ type CustomCommand struct {
|
||||
}
|
||||
|
||||
type CustomCommandPrompt struct {
|
||||
Type string `yaml:"type"` // one of 'input', 'menu', or 'confirm'
|
||||
// one of 'input', 'menu', 'confirm', or 'menuFromCommand'
|
||||
Type string `yaml:"type"`
|
||||
|
||||
Title string `yaml:"title"`
|
||||
|
||||
// this only apply to input prompts
|
||||
|
||||
@@ -4,8 +4,11 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests"
|
||||
)
|
||||
@@ -47,6 +50,14 @@ func getTestsToRun(testNames []string) []*components.IntegrationTest {
|
||||
return tests.Tests
|
||||
}
|
||||
|
||||
testNames = slices.Map(testNames, func(name string) string {
|
||||
// allowing full test paths to be passed for convenience
|
||||
return strings.TrimSuffix(
|
||||
regexp.MustCompile(`.*pkg/integration/tests/`).ReplaceAllString(name, ""),
|
||||
".go",
|
||||
)
|
||||
})
|
||||
|
||||
outer:
|
||||
for _, testName := range testNames {
|
||||
// check if our given test name actually exists
|
||||
|
||||
34
pkg/integration/tests/custom_commands/basic.go
Normal file
34
pkg/integration/tests/custom_commands/basic.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package custom_commands
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var Basic = components.NewIntegrationTest(components.NewIntegrationTestArgs{
|
||||
Description: "Using a custom command to create a new file",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupRepo: func(shell *components.Shell) {},
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
cfg.UserConfig.CustomCommands = []config.CustomCommand{
|
||||
{
|
||||
Key: "a",
|
||||
Context: "files",
|
||||
Command: "touch myfile",
|
||||
},
|
||||
}
|
||||
},
|
||||
Run: func(
|
||||
shell *components.Shell,
|
||||
input *components.Input,
|
||||
assert *components.Assert,
|
||||
keys config.KeybindingConfig,
|
||||
) {
|
||||
assert.WorkingTreeFileCount(0)
|
||||
|
||||
input.PressKeys("a")
|
||||
assert.WorkingTreeFileCount(1)
|
||||
assert.SelectedLineContains("myfile")
|
||||
},
|
||||
})
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/branch"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/commit"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
||||
)
|
||||
|
||||
@@ -15,4 +16,5 @@ var Tests = []*components.IntegrationTest{
|
||||
commit.NewBranch,
|
||||
branch.Suggestions,
|
||||
interactive_rebase.One,
|
||||
custom_commands.Basic,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user