This commit is contained in:
Jesse Duffield 2022-08-12 09:24:39 +10:00
parent b8d9443999
commit faed509bfd
6 changed files with 10 additions and 32 deletions

View file

@ -2,7 +2,6 @@ package custom_commands
import ( import (
"bytes" "bytes"
"fmt"
"text/template" "text/template"
"github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/common"
@ -106,13 +105,6 @@ func (self *Resolver) resolveMenuOption(option *config.CustomCommandMenuOption,
}, nil }, nil
} }
func main() {
fmt.Println(ResolveTemplate("old approach: {{index .PromptResponses 0}}, new approach: {{ .Form.a }}", CustomCommandObject{
PromptResponses: []string{"a"},
Form: map[string]string{"a": "B"},
}))
}
type CustomCommandObject struct { type CustomCommandObject struct {
// deprecated. Use Responses instead // deprecated. Use Responses instead
PromptResponses []string PromptResponses []string

View file

@ -117,9 +117,9 @@ func (self *Input) Log(message string) {
// this will look for a list item in the current panel and if it finds it, it will // this will look for a list item in the current panel and if it finds it, it will
// enter the keypresses required to navigate to it. // enter the keypresses required to navigate to it.
// The test will fail if: // The test will fail if:
// - the user is not in a list item // - the user is not in a list item
// - no list item is found containing the given text // - no list item is found containing the given text
// - multiple list items are found containing the given text in the initial page of items // - multiple list items are found containing the given text in the initial page of items
// //
// NOTE: this currently assumes that ViewBufferLines returns all the lines that can be accessed. // NOTE: this currently assumes that ViewBufferLines returns all the lines that can be accessed.
// If this changes in future, we'll need to update this code to first attempt to find the item // If this changes in future, we'll need to update this code to first attempt to find the item

View file

@ -101,7 +101,7 @@ func RunTests(
switch mode { switch mode {
case UPDATE_SNAPSHOT: case UPDATE_SNAPSHOT:
if err := updateSnapshot(logf, actualDir, expectedDir); err != nil { if err := updateSnapshot(actualDir, expectedDir); err != nil {
return err return err
} }
logf("Test passed: %s", test.Name()) logf("Test passed: %s", test.Name())
@ -112,7 +112,7 @@ func RunTests(
logf("Test passed: %s", test.Name()) logf("Test passed: %s", test.Name())
case ASK_TO_UPDATE_SNAPSHOT: case ASK_TO_UPDATE_SNAPSHOT:
if _, err := os.Stat(expectedDir); os.IsNotExist(err) { if _, err := os.Stat(expectedDir); os.IsNotExist(err) {
if err := updateSnapshot(logf, actualDir, expectedDir); err != nil { if err := updateSnapshot(actualDir, expectedDir); err != nil {
return err return err
} }
logf("No existing snapshot found for %s. Created snapshot.", test.Name()) logf("No existing snapshot found for %s. Created snapshot.", test.Name())
@ -125,7 +125,7 @@ func RunTests(
// prompt user whether to update the snapshot (Y/N) // prompt user whether to update the snapshot (Y/N)
if promptUserToUpdateSnapshot() { if promptUserToUpdateSnapshot() {
if err := updateSnapshot(logf, actualDir, expectedDir); err != nil { if err := updateSnapshot(actualDir, expectedDir); err != nil {
return err return err
} }
logf("Snapshot updated: %s", test.Name()) logf("Snapshot updated: %s", test.Name())
@ -153,7 +153,7 @@ func promptUserToUpdateSnapshot() bool {
return input == "y" return input == "y"
} }
func updateSnapshot(logf logf, actualDir string, expectedDir string) error { func updateSnapshot(actualDir string, expectedDir string) error {
// create/update snapshot // create/update snapshot
err := oscommands.CopyDir(actualDir, expectedDir) err := oscommands.CopyDir(actualDir, expectedDir)
if err != nil { if err != nil {

View file

@ -15,6 +15,7 @@ import (
"testing" "testing"
"github.com/creack/pty" "github.com/creack/pty"
"github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )

View file

@ -7,6 +7,7 @@ import (
"github.com/jesseduffield/generics/slices" "github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/integration" "github.com/jesseduffield/lazygit/pkg/integration"
"github.com/jesseduffield/lazygit/pkg/integration/components"
) )
// see pkg/integration/README.md // see pkg/integration/README.md

View file

@ -11,6 +11,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui" "github.com/jesseduffield/lazygit/pkg/gui"
"github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/integration" "github.com/jesseduffield/lazygit/pkg/integration"
"github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/secureexec" "github.com/jesseduffield/lazygit/pkg/secureexec"
) )
@ -31,23 +32,6 @@ func (app *App) getCurrentTest() *components.IntegrationTest {
return nil return nil
} }
func (app *App) refreshTests() {
app.loadTests()
app.g.Update(func(*gocui.Gui) error {
listView, err := app.g.View("list")
if err != nil {
return err
}
listView.Clear()
for _, test := range app.tests {
fmt.Fprintln(listView, test.Name())
}
return nil
})
}
func (app *App) loadTests() { func (app *App) loadTests() {
app.tests = integration.Tests app.tests = integration.Tests
if app.itemIdx > len(app.tests)-1 { if app.itemIdx > len(app.tests)-1 {