Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LIFE-307] Don't link to orb docs on server #1064

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/orb.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func formatListOrbsResult(list api.OrbsForListing, opts orbOptions) (string, err
}
}

if !opts.private {
if !opts.private && opts.cfg.Host == defaultHost {
b.WriteString("\nIn order to see more details about each orb, type: `circleci orb info orb-namespace/orb-name`\n")
b.WriteString("\nSearch, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/")
}
Expand Down
93 changes: 77 additions & 16 deletions cmd/orb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2229,9 +2229,6 @@ second (0.8.0)
third (0.9.0)
first (0.7.0)

In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `

Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/
`))
})

Expand All @@ -2256,9 +2253,6 @@ third (0.9.0)
first (0.7.0)
second (0.8.0)

In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `

Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/
`))
})

Expand All @@ -2283,9 +2277,6 @@ second (0.8.0)
first (0.7.0)
third (0.9.0)

In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `

Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/
`))
})
})
Expand Down Expand Up @@ -2396,7 +2387,83 @@ query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {
})
})

Describe("when listing all orbs with --uncertified", func() {
Describe("when listing all orbs default host", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"orb", "list",
"--skip-update-check",
)
By("setting up a mock server")

query := `
query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {
orbs(first: 20, after: $after, certifiedOnly: $certifiedOnly) {
totalCount,
edges {
cursor
node {
name
statistics {
last30DaysBuildCount,
last30DaysProjectCount,
last30DaysOrganizationCount
}
versions(count: 1) {
version,
source
}
}
}
pageInfo {
hasNextPage
}
}
}
`

firstRequest := graphql.NewRequest(query)
firstRequest.Variables["after"] = ""
firstRequest.Variables["certifiedOnly"] = false

firstRequestEncoded, err := firstRequest.Encode()
Expect(err).ShouldNot(HaveOccurred())

secondRequest := graphql.NewRequest(query)
secondRequest.Variables["after"] = "test/here-we-go"
secondRequest.Variables["certifiedOnly"] = false

secondRequestEncoded, err := secondRequest.Encode()
Expect(err).ShouldNot(HaveOccurred())

tmpBytes := golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_uncertified/first_response.json"))
firstResponse := string(tmpBytes)

tmpBytes = golden.Get(GinkgoT(), filepath.FromSlash("gql_orb_list_uncertified/second_response.json"))
secondResponse := string(tmpBytes)

tempSettings.AppendPostHandler("", clitest.MockRequestResponse{
Status: http.StatusOK,
Request: firstRequestEncoded.String(),
Response: firstResponse,
})
tempSettings.AppendPostHandler("", clitest.MockRequestResponse{
Status: http.StatusOK,
Request: secondRequestEncoded.String(),
Response: secondResponse,
})
})

It("includes a link to the docs'", func() {
By("running the command")
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)

Expect(err).ShouldNot(HaveOccurred())
Eventually(session.Out).Should(gbytes.Say("In order to see more details about each orb, type: `circleci orb info orb-namespace/orb-name`"))
Eventually(session.Out).Should(gbytes.Say("Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/"))
})
})

Describe("when listing all orbs with --uncertified and custom host", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"orb", "list",
Expand Down Expand Up @@ -2475,9 +2542,6 @@ query ListOrbs ($after: String!, $certifiedOnly: Boolean!) {
Eventually(session.Out).Should(gbytes.Say("circleci/codecov-clojure \\(0.0.4\\)"))
// Include an orb with contents from the second mocked response
Eventually(session.Out).Should(gbytes.Say("zzak/test4 \\(0.1.0\\)"))

Eventually(session.Out).Should(gbytes.Say("In order to see more details about each orb, type: `circleci orb info orb-namespace/orb-name`"))
Eventually(session.Out).Should(gbytes.Say("Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/"))
Expect(tempSettings.TestServer.ReceivedRequests()).Should(HaveLen(2))
})

Expand Down Expand Up @@ -2584,9 +2648,6 @@ foo/test (0.7.0)
- last30DaysOrganizationCount: 0
- last30DaysProjectCount: 0

In order to see more details about each orb, type: ` + "`circleci orb info orb-namespace/orb-name`" + `

Search, filter, and view sources for all Orbs online at https://circleci.com/developer/orbs/
`))
Eventually(session).Should(gexec.Exit(0))
Expect(tempSettings.TestServer.ReceivedRequests()).Should(HaveLen(1))
Expand Down