Skip to content

Commit

Permalink
Add --show-error to CurlWithCustomReporter
Browse files Browse the repository at this point in the history
Use long-form flags to make the errors more readable.
  • Loading branch information
davewalter committed Feb 22, 2025
1 parent 7f027e7 commit e0c7dc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions helpers/internal/curl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ func Curl(cmdStarter internal.Starter, skipSsl bool, args ...string) *gexec.Sess
}

func CurlWithCustomReporter(cmdStarter internal.Starter, reporter internal.Reporter, skipSsl bool, args ...string) *gexec.Session {
curlArgs := append([]string{"-s"}, args...)
curlArgs = append([]string{"-H", "Expect:"}, curlArgs...)
curlArgs := append([]string{"--silent"}, args...)
curlArgs = append([]string{"--show-error"}, curlArgs...)
curlArgs = append([]string{"--header", "Expect:"}, curlArgs...)
if skipSsl {
curlArgs = append([]string{"-k"}, curlArgs...)
curlArgs = append([]string{"--insecure"}, curlArgs...)
}

request, err := cmdStarter.Start(reporter, "curl", curlArgs...)
Expand Down
2 changes: 1 addition & 1 deletion helpers/internal/curl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("Curl", func() {
Expect(session).To(Exit(0))
Expect(session.Out).To(Say("HTTP/1.1 200 OK"))
Expect(starter.CalledWith[0].Executable).To(Equal("curl"))
Expect(starter.CalledWith[0].Args).To(ConsistOf("-H", "Expect:", "-I", "-s", "http://example.com"))
Expect(starter.CalledWith[0].Args).To(ConsistOf("--header", "Expect:", "-I", "--show-error", "--silent", "http://example.com"))
})

It("uses the specified reporter", func() {
Expand Down

0 comments on commit e0c7dc9

Please sign in to comment.