mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
rename helpers to components
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package helpers
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package helpers
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package helpers
|
||||
package components
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package helpers
|
||||
package components
|
||||
|
||||
import (
|
||||
"os"
|
@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"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/stretchr/testify/assert"
|
||||
)
|
||||
@ -45,7 +45,7 @@ type (
|
||||
func RunTests(
|
||||
logf logf,
|
||||
runCmd func(cmd *exec.Cmd) error,
|
||||
fnWrapper func(test *helpers.IntegrationTest, f func() error),
|
||||
fnWrapper func(test *components.IntegrationTest, f func() error),
|
||||
mode Mode,
|
||||
includeSkipped bool,
|
||||
) error {
|
||||
@ -229,12 +229,12 @@ func compareSnapshots(logf logf, configDir string, actualDir string, expectedDir
|
||||
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 {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
shell := helpers.NewShell()
|
||||
shell := components.NewShell()
|
||||
shell.RunCommand("git init")
|
||||
shell.RunCommand(`git config user.email "CI@example.com"`)
|
||||
shell.RunCommand(`git config user.name "CI"`)
|
||||
@ -249,7 +249,7 @@ func createFixture(test *helpers.IntegrationTest, actualDir string, rootDir stri
|
||||
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()
|
||||
|
||||
templateConfigDir := filepath.Join(rootDir, "test", "default_test_config")
|
||||
|
@ -15,7 +15,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/creack/pty"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@ -34,7 +33,7 @@ func TestIntegration(t *testing.T) {
|
||||
err := RunTests(
|
||||
t.Logf,
|
||||
runCmdHeadless,
|
||||
func(test *helpers.IntegrationTest, f func() error) {
|
||||
func(test *components.IntegrationTest, f func() error) {
|
||||
defer func() { testNumber += 1 }()
|
||||
if testNumber%parallelTotal != parallelIndex {
|
||||
return
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/jesseduffield/generics/slices"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
||||
)
|
||||
|
||||
// see pkg/integration/README.md
|
||||
@ -17,7 +16,7 @@ import (
|
||||
func main() {
|
||||
mode := integration.GetModeFromEnv()
|
||||
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
|
||||
var testsToRun []*helpers.IntegrationTest
|
||||
var testsToRun []*components.IntegrationTest
|
||||
|
||||
if len(os.Args) > 1 {
|
||||
outer:
|
||||
@ -35,14 +34,14 @@ func main() {
|
||||
testsToRun = integration.Tests
|
||||
}
|
||||
|
||||
testNames := slices.Map(testsToRun, func(test *helpers.IntegrationTest) string {
|
||||
testNames := slices.Map(testsToRun, func(test *components.IntegrationTest) string {
|
||||
return test.Name()
|
||||
})
|
||||
|
||||
err := integration.RunTests(
|
||||
log.Printf,
|
||||
runCmdInTerminal,
|
||||
func(test *helpers.IntegrationTest, f func() error) {
|
||||
func(test *components.IntegrationTest, f func() error) {
|
||||
if !slices.Contains(testNames, test.Name()) {
|
||||
return
|
||||
}
|
||||
|
@ -2,15 +2,15 @@ package branch
|
||||
|
||||
import (
|
||||
"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",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *helpers.Shell) {
|
||||
SetupRepo: func(shell *components.Shell) {
|
||||
shell.
|
||||
EmptyCommit("my commit message").
|
||||
NewBranch("new-branch").
|
||||
@ -20,7 +20,7 @@ var Suggestions = helpers.NewIntegrationTest(helpers.NewIntegrationTestArgs{
|
||||
NewBranch("other-new-branch-2").
|
||||
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.PressKeys(keys.Branches.CheckoutBranchByName)
|
||||
|
@ -2,19 +2,19 @@ package commit
|
||||
|
||||
import (
|
||||
"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",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *helpers.Shell) {
|
||||
SetupRepo: func(shell *components.Shell) {
|
||||
shell.CreateFile("myfile", "myfile 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)
|
||||
|
||||
input.Select()
|
||||
|
@ -2,21 +2,21 @@ package commit
|
||||
|
||||
import (
|
||||
"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",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *helpers.Shell) {
|
||||
SetupRepo: func(shell *components.Shell) {
|
||||
shell.
|
||||
EmptyCommit("commit 1").
|
||||
EmptyCommit("commit 2").
|
||||
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)
|
||||
|
||||
input.SwitchToCommitsWindow()
|
||||
|
@ -2,19 +2,19 @@ package interactive_rebase
|
||||
|
||||
import (
|
||||
"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",
|
||||
ExtraCmdArgs: "",
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *helpers.Shell) {
|
||||
SetupRepo: func(shell *components.Shell) {
|
||||
shell.
|
||||
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()
|
||||
assert.CurrentViewName("commits")
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package tests
|
||||
|
||||
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/commit"
|
||||
"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,
|
||||
// be sure to add it to this list.
|
||||
|
||||
var Tests = []*helpers.IntegrationTest{
|
||||
var Tests = []*components.IntegrationTest{
|
||||
commit.Commit,
|
||||
commit.NewBranch,
|
||||
branch.Suggestions,
|
||||
|
@ -11,21 +11,20 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||
)
|
||||
|
||||
// this program lets you manage integration tests in a TUI. See pkg/integration/README.md for more info.
|
||||
|
||||
type App struct {
|
||||
tests []*helpers.IntegrationTest
|
||||
tests []*components.IntegrationTest
|
||||
itemIdx int
|
||||
testDir string
|
||||
filtering bool
|
||||
g *gocui.Gui
|
||||
}
|
||||
|
||||
func (app *App) getCurrentTest() *helpers.IntegrationTest {
|
||||
func (app *App) getCurrentTest() *components.IntegrationTest {
|
||||
if len(app.tests) > 0 {
|
||||
return app.tests[app.itemIdx]
|
||||
}
|
||||
|
Reference in New Issue
Block a user