From b9a8a18d8fe40aeb34cf5e94257a2c700dc19e66 Mon Sep 17 00:00:00 2001 From: Ehsan-saradar Date: Wed, 20 Dec 2023 16:02:28 +0330 Subject: [PATCH] Fix lint and integration test --- integration/marketplace/list_test.go | 6 ++++-- marketplace/cmd/info.go | 2 -- marketplace/cmd/marketplace.go | 3 +-- marketplace/pkg/apps/search.go | 10 +++++----- marketplace/pkg/tree/tree.go | 10 +++++----- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/integration/marketplace/list_test.go b/integration/marketplace/list_test.go index 6324d9ed..fa4d2384 100644 --- a/integration/marketplace/list_test.go +++ b/integration/marketplace/list_test.go @@ -4,7 +4,7 @@ import ( "bytes" "os" "path/filepath" - "regexp" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -69,5 +69,7 @@ func TestMarketplace(t *testing.T) { step.Stdout(buf), )), )) - assert.Regexp(regexp.MustCompile("šŸŽ‰ Found [0-9]+ results"), buf.String()) + assert.Condition(func() bool { + return strings.HasPrefix(buf.String(), "āŒ") || strings.HasPrefix(buf.String(), "šŸ“¦") + }, "unexpected output: %s", buf.String()) } diff --git a/marketplace/cmd/info.go b/marketplace/cmd/info.go index 1981e21e..6dc56843 100644 --- a/marketplace/cmd/info.go +++ b/marketplace/cmd/info.go @@ -15,8 +15,6 @@ import ( "github.com/spf13/cobra" ) -const igniteCLIPackage = "github.com/ignite/cli" - var ( linkStyle = lipgloss.NewStyle(). Foreground(lipgloss.Color("10")). diff --git a/marketplace/cmd/marketplace.go b/marketplace/cmd/marketplace.go index ac9bf1b4..e91b4c49 100644 --- a/marketplace/cmd/marketplace.go +++ b/marketplace/cmd/marketplace.go @@ -19,8 +19,7 @@ func NewMarketplace() *cobra.Command { Long: `Marketplace is a command line tool that helps you to search for ignite apps using GitHub search API. It also helps you to get more information about an app. Please note that Github API has a very limited rate limit for unauthenticated requests - so it's recommended to set GITHUB_TOKEN environment variable to your GitHub access token - if you want to use marketplace commands frequently.`, + so it's recommended to use the --github-token flag you want to use marketplace commands frequently.`, SilenceUsage: true, SilenceErrors: true, } diff --git a/marketplace/pkg/apps/search.go b/marketplace/pkg/apps/search.go index 48bddc8b..a98c4b18 100644 --- a/marketplace/pkg/apps/search.go +++ b/marketplace/pkg/apps/search.go @@ -58,11 +58,11 @@ func Search(ctx context.Context, client *xgithub.Client, query string, minStars result = append(result, AppRepository{ PackageURL: fmt.Sprintf("github.com/%s/%s", repo.GetOwner().GetLogin(), repo.GetName()), - Name: repo.GetName(), - Owner: repo.GetOwner().GetLogin(), - Stars: repo.GetStargazersCount(), - UpdatedAt: repo.GetPushedAt().Time, - Apps: apps, + Name: repo.GetName(), + Owner: repo.GetOwner().GetLogin(), + Stars: repo.GetStargazersCount(), + UpdatedAt: repo.GetPushedAt().Time, + Apps: apps, }) } diff --git a/marketplace/pkg/tree/tree.go b/marketplace/pkg/tree/tree.go index a59583ae..26815332 100644 --- a/marketplace/pkg/tree/tree.go +++ b/marketplace/pkg/tree/tree.go @@ -25,11 +25,11 @@ func (n *Node) AddChild(child *Node) { } // Format implements fmt.Formatter. -func (n *Node) Format(f fmt.State, verb rune) { - fprintNode(f, verb, "", n) +func (n *Node) Format(f fmt.State, _ rune) { + fprintNode(f, "", n) } -func fprintNode(f fmt.State, verb rune, prefix string, n *Node) { +func fprintNode(f fmt.State, prefix string, n *Node) { fmt.Fprintln(f, n.Text) width := 2 @@ -47,10 +47,10 @@ func fprintNode(f fmt.State, verb rune, prefix string, n *Node) { } if i < len(n.Children)-1 { fmt.Fprintf(f, "%sā”œ%s ", prefix, strings.Repeat("ā”€", width)) - fprintNode(f, verb, prefix+"ā”‚"+strings.Repeat(" ", width+1), child) + fprintNode(f, prefix+"ā”‚"+strings.Repeat(" ", width+1), child) } else { fmt.Fprintf(f, "%sā””%s ", prefix, strings.Repeat("ā”€", width)) - fprintNode(f, verb, prefix+strings.Repeat(" ", width+2), child) + fprintNode(f, prefix+strings.Repeat(" ", width+2), child) } } }