mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-25 00:46:54 +02:00
rename helpers to components
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
package helpers
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package helpers
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package helpers
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -1,4 +1,4 @@
|
|||||||
package helpers
|
package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
"github.com/jesseduffield/generics/slices"
|
"github.com/jesseduffield/generics/slices"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -45,7 +45,7 @@ type (
|
|||||||
func RunTests(
|
func RunTests(
|
||||||
logf logf,
|
logf logf,
|
||||||
runCmd func(cmd *exec.Cmd) error,
|
runCmd func(cmd *exec.Cmd) error,
|
||||||
fnWrapper func(test *helpers.IntegrationTest, f func() error),
|
fnWrapper func(test *components.IntegrationTest, f func() error),
|
||||||
mode Mode,
|
mode Mode,
|
||||||
includeSkipped bool,
|
includeSkipped bool,
|
||||||
) error {
|
) error {
|
||||||
@ -229,12 +229,12 @@ func compareSnapshots(logf logf, configDir string, actualDir string, expectedDir
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFixture(test *helpers.IntegrationTest, actualDir string, rootDir string) error {
|
func createFixture(test *components.IntegrationTest, actualDir string, rootDir string) error {
|
||||||
if err := os.Chdir(actualDir); err != nil {
|
if err := os.Chdir(actualDir); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
shell := helpers.NewShell()
|
shell := components.NewShell()
|
||||||
shell.RunCommand("git init")
|
shell.RunCommand("git init")
|
||||||
shell.RunCommand(`git config user.email "CI@example.com"`)
|
shell.RunCommand(`git config user.email "CI@example.com"`)
|
||||||
shell.RunCommand(`git config user.name "CI"`)
|
shell.RunCommand(`git config user.name "CI"`)
|
||||||
@ -249,7 +249,7 @@ func createFixture(test *helpers.IntegrationTest, actualDir string, rootDir stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLazygitCommand(test *helpers.IntegrationTest, testPath string, rootDir string) (*exec.Cmd, error) {
|
func getLazygitCommand(test *components.IntegrationTest, testPath string, rootDir string) (*exec.Cmd, error) {
|
||||||
osCommand := oscommands.NewDummyOSCommand()
|
osCommand := oscommands.NewDummyOSCommand()
|
||||||
|
|
||||||
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
|
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/creack/pty"
|
"github.com/creack/pty"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,7 +33,7 @@ func TestIntegration(t *testing.T) {
|
|||||||
err := RunTests(
|
err := RunTests(
|
||||||
t.Logf,
|
t.Logf,
|
||||||
runCmdHeadless,
|
runCmdHeadless,
|
||||||
func(test *helpers.IntegrationTest, f func() error) {
|
func(test *components.IntegrationTest, f func() error) {
|
||||||
defer func() { testNumber += 1 }()
|
defer func() { testNumber += 1 }()
|
||||||
if testNumber%parallelTotal != parallelIndex {
|
if testNumber%parallelTotal != parallelIndex {
|
||||||
return
|
return
|
||||||
|
@ -7,7 +7,6 @@ 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/helpers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// see pkg/integration/README.md
|
// see pkg/integration/README.md
|
||||||
@ -17,7 +16,7 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
mode := integration.GetModeFromEnv()
|
mode := integration.GetModeFromEnv()
|
||||||
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
|
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
|
||||||
var testsToRun []*helpers.IntegrationTest
|
var testsToRun []*components.IntegrationTest
|
||||||
|
|
||||||
if len(os.Args) > 1 {
|
if len(os.Args) > 1 {
|
||||||
outer:
|
outer:
|
||||||
@ -35,14 +34,14 @@ func main() {
|
|||||||
testsToRun = integration.Tests
|
testsToRun = integration.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
testNames := slices.Map(testsToRun, func(test *helpers.IntegrationTest) string {
|
testNames := slices.Map(testsToRun, func(test *components.IntegrationTest) string {
|
||||||
return test.Name()
|
return test.Name()
|
||||||
})
|
})
|
||||||
|
|
||||||
err := integration.RunTests(
|
err := integration.RunTests(
|
||||||
log.Printf,
|
log.Printf,
|
||||||
runCmdInTerminal,
|
runCmdInTerminal,
|
||||||
func(test *helpers.IntegrationTest, f func() error) {
|
func(test *components.IntegrationTest, f func() error) {
|
||||||
if !slices.Contains(testNames, test.Name()) {
|
if !slices.Contains(testNames, test.Name()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@ package branch
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Suggestions = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
var Suggestions = components.NewIntegrationTest(components.NewIntegrationTestArgs{
|
||||||
Description: "Checking out a branch with name suggestions",
|
Description: "Checking out a branch with name suggestions",
|
||||||
ExtraCmdArgs: "",
|
ExtraCmdArgs: "",
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {},
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
SetupRepo: func(shell *helpers.Shell) {
|
SetupRepo: func(shell *components.Shell) {
|
||||||
shell.
|
shell.
|
||||||
EmptyCommit("my commit message").
|
EmptyCommit("my commit message").
|
||||||
NewBranch("new-branch").
|
NewBranch("new-branch").
|
||||||
@ -20,7 +20,7 @@ var Suggestions = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
|||||||
NewBranch("other-new-branch-2").
|
NewBranch("other-new-branch-2").
|
||||||
NewBranch("other-new-branch-3")
|
NewBranch("other-new-branch-3")
|
||||||
},
|
},
|
||||||
Run: func(shell *helpers.Shell, input *helpers.Input, assert *helpers.Assert, keys config.KeybindingConfig) {
|
Run: func(shell *components.Shell, input *components.Input, assert *components.Assert, keys config.KeybindingConfig) {
|
||||||
input.SwitchToBranchesWindow()
|
input.SwitchToBranchesWindow()
|
||||||
|
|
||||||
input.PressKeys(keys.Branches.CheckoutBranchByName)
|
input.PressKeys(keys.Branches.CheckoutBranchByName)
|
||||||
|
@ -2,19 +2,19 @@ package commit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Commit = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
var Commit = components.NewIntegrationTest(components.NewIntegrationTestArgs{
|
||||||
Description: "Staging a couple files and committing",
|
Description: "Staging a couple files and committing",
|
||||||
ExtraCmdArgs: "",
|
ExtraCmdArgs: "",
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {},
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
SetupRepo: func(shell *helpers.Shell) {
|
SetupRepo: func(shell *components.Shell) {
|
||||||
shell.CreateFile("myfile", "myfile content")
|
shell.CreateFile("myfile", "myfile content")
|
||||||
shell.CreateFile("myfile2", "myfile2 content")
|
shell.CreateFile("myfile2", "myfile2 content")
|
||||||
},
|
},
|
||||||
Run: func(shell *helpers.Shell, input *helpers.Input, assert *helpers.Assert, keys config.KeybindingConfig) {
|
Run: func(shell *components.Shell, input *components.Input, assert *components.Assert, keys config.KeybindingConfig) {
|
||||||
assert.CommitCount(0)
|
assert.CommitCount(0)
|
||||||
|
|
||||||
input.Select()
|
input.Select()
|
||||||
|
@ -2,21 +2,21 @@ package commit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
var NewBranch = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
var NewBranch = components.NewIntegrationTest(components.NewIntegrationTestArgs{
|
||||||
Description: "Creating a new branch from a commit",
|
Description: "Creating a new branch from a commit",
|
||||||
ExtraCmdArgs: "",
|
ExtraCmdArgs: "",
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {},
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
SetupRepo: func(shell *helpers.Shell) {
|
SetupRepo: func(shell *components.Shell) {
|
||||||
shell.
|
shell.
|
||||||
EmptyCommit("commit 1").
|
EmptyCommit("commit 1").
|
||||||
EmptyCommit("commit 2").
|
EmptyCommit("commit 2").
|
||||||
EmptyCommit("commit 3")
|
EmptyCommit("commit 3")
|
||||||
},
|
},
|
||||||
Run: func(shell *helpers.Shell, input *helpers.Input, assert *helpers.Assert, keys config.KeybindingConfig) {
|
Run: func(shell *components.Shell, input *components.Input, assert *components.Assert, keys config.KeybindingConfig) {
|
||||||
assert.CommitCount(3)
|
assert.CommitCount(3)
|
||||||
|
|
||||||
input.SwitchToCommitsWindow()
|
input.SwitchToCommitsWindow()
|
||||||
|
@ -2,19 +2,19 @@ package interactive_rebase
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
)
|
)
|
||||||
|
|
||||||
var One = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
var One = components.NewIntegrationTest(components.NewIntegrationTestArgs{
|
||||||
Description: "Begins an interactive rebase, then fixups, drops, and squashes some commits",
|
Description: "Begins an interactive rebase, then fixups, drops, and squashes some commits",
|
||||||
ExtraCmdArgs: "",
|
ExtraCmdArgs: "",
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {},
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
SetupRepo: func(shell *helpers.Shell) {
|
SetupRepo: func(shell *components.Shell) {
|
||||||
shell.
|
shell.
|
||||||
CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01
|
CreateNCommits(5) // these will appears at commit 05, 04, 04, down to 01
|
||||||
},
|
},
|
||||||
Run: func(shell *helpers.Shell, input *helpers.Input, assert *helpers.Assert, keys config.KeybindingConfig) {
|
Run: func(shell *components.Shell, input *components.Input, assert *components.Assert, keys config.KeybindingConfig) {
|
||||||
input.SwitchToCommitsWindow()
|
input.SwitchToCommitsWindow()
|
||||||
assert.CurrentViewName("commits")
|
assert.CurrentViewName("commits")
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
"github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/branch"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/branch"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/commit"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/commit"
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
"github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase"
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
// Here is where we lists the actual tests that will run. When you create a new test,
|
// Here is where we lists the actual tests that will run. When you create a new test,
|
||||||
// be sure to add it to this list.
|
// be sure to add it to this list.
|
||||||
|
|
||||||
var Tests = []*helpers.IntegrationTest{
|
var Tests = []*components.IntegrationTest{
|
||||||
commit.Commit,
|
commit.Commit,
|
||||||
commit.NewBranch,
|
commit.NewBranch,
|
||||||
branch.Suggestions,
|
branch.Suggestions,
|
||||||
|
@ -11,21 +11,20 @@ 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/helpers"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this program lets you manage integration tests in a TUI. See pkg/integration/README.md for more info.
|
// this program lets you manage integration tests in a TUI. See pkg/integration/README.md for more info.
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
tests []*helpers.IntegrationTest
|
tests []*components.IntegrationTest
|
||||||
itemIdx int
|
itemIdx int
|
||||||
testDir string
|
testDir string
|
||||||
filtering bool
|
filtering bool
|
||||||
g *gocui.Gui
|
g *gocui.Gui
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *App) getCurrentTest() *helpers.IntegrationTest {
|
func (app *App) getCurrentTest() *components.IntegrationTest {
|
||||||
if len(app.tests) > 0 {
|
if len(app.tests) > 0 {
|
||||||
return app.tests[app.itemIdx]
|
return app.tests[app.itemIdx]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user