diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-24 13:06:42 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-30 18:51:23 +1000 |
commit | e33fe37a99d4b3866970b1b2f40169d1bc9afa2e (patch) | |
tree | 0027f612fb72b2603044d04389da0236df28d864 /pkg/integration | |
parent | ea54cb6e9c07ebca4a53e691fcb3cf993c793a50 (diff) |
Standardise on using lo for slice functions
We've been sometimes using lo and sometimes using my slices package, and we need to pick one
for consistency. Lo is more extensive and better maintained so we're going with that.
My slices package was a superset of go's own slices package so in some places I've just used
the official one (the methods were just wrappers anyway).
I've also moved the remaining methods into the utils package.
Diffstat (limited to 'pkg/integration')
-rw-r--r-- | pkg/integration/clients/cli.go | 3 | ||||
-rw-r--r-- | pkg/integration/clients/tui.go | 4 | ||||
-rw-r--r-- | pkg/integration/components/test.go | 4 | ||||
-rw-r--r-- | pkg/integration/tests/tests.go | 6 |
4 files changed, 8 insertions, 9 deletions
diff --git a/pkg/integration/clients/cli.go b/pkg/integration/clients/cli.go index 8ac9947e9..79853b224 100644 --- a/pkg/integration/clients/cli.go +++ b/pkg/integration/clients/cli.go @@ -8,7 +8,6 @@ import ( "strconv" "strings" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/integration/components" "github.com/jesseduffield/lazygit/pkg/integration/tests" "github.com/samber/lo" @@ -58,7 +57,7 @@ func getTestsToRun(testNames []string) []*components.IntegrationTest { return allIntegrationTests } - testNames = slices.Map(testNames, func(name string) string { + testNames = lo.Map(testNames, func(name string, _ int) string { // allowing full test paths to be passed for convenience return strings.TrimSuffix( regexp.MustCompile(`.*pkg/integration/tests/`).ReplaceAllString(name, ""), diff --git a/pkg/integration/clients/tui.go b/pkg/integration/clients/tui.go index 7d82a6630..78180cae6 100644 --- a/pkg/integration/clients/tui.go +++ b/pkg/integration/clients/tui.go @@ -7,7 +7,6 @@ import ( "path/filepath" "strings" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazycore/pkg/utils" "github.com/jesseduffield/lazygit/pkg/gui" @@ -15,6 +14,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/components" "github.com/jesseduffield/lazygit/pkg/integration/tests" "github.com/jesseduffield/lazygit/pkg/secureexec" + "github.com/samber/lo" ) // This program lets you run integration tests from a TUI. See pkg/integration/README.md for more info. @@ -245,7 +245,7 @@ func (self *app) filterWithString(needle string) { if needle == "" { self.filteredTests = self.allTests } else { - self.filteredTests = slices.Filter(self.allTests, func(test *components.IntegrationTest) bool { + self.filteredTests = lo.Filter(self.allTests, func(test *components.IntegrationTest, _ int) bool { return strings.Contains(test.Name(), needle) }) } diff --git a/pkg/integration/components/test.go b/pkg/integration/components/test.go index ca73ba805..2520ec47e 100644 --- a/pkg/integration/components/test.go +++ b/pkg/integration/components/test.go @@ -5,11 +5,11 @@ import ( "strconv" "strings" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/config" integrationTypes "github.com/jesseduffield/lazygit/pkg/integration/types" "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/samber/lo" ) // IntegrationTest describes an integration test that will be run against the lazygit gui. @@ -102,7 +102,7 @@ func (self GitVersionRestriction) shouldRunOnVersion(version *git_commands.GitVe return version.IsOlderThanVersion(before) } if len(self.includes) != 0 { - return slices.Some(self.includes, func(str string) bool { + return lo.SomeBy(self.includes, func(str string) bool { v, err := git_commands.ParseGitVersion(str) if err != nil { panic("Invalid git version string: " + str) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 2134aa302..600c98af6 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -9,18 +9,18 @@ import ( "strings" "github.com/jesseduffield/generics/set" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazycore/pkg/utils" "github.com/jesseduffield/lazygit/pkg/integration/components" + "github.com/samber/lo" ) func GetTests() []*components.IntegrationTest { // first we ensure that each test in this directory has actually been added to the above list. testCount := 0 - testNamesSet := set.NewFromSlice(slices.Map( + testNamesSet := set.NewFromSlice(lo.Map( tests, - func(test *components.IntegrationTest) string { + func(test *components.IntegrationTest, _ int) string { return test.Name() }, )) |