Skip to content

Commit

Permalink
Expose HTTP details of last run
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop committed Oct 30, 2024
1 parent b98606d commit 9020830
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ func (r *readSeekNopCloser) Close() error {
return nil
}

func (c *Client) buildBody() io.ReadSeekCloser {
func (c *Client) buildBody() io.Reader {
if len(c.reqBody) > 0 {
return &readSeekNopCloser{ReadSeeker: bytes.NewReader(c.reqBody)}
}
Expand Down
11 changes: 11 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ func TestNewClient(t *testing.T) {
val, found := vars.Get("$var1")
assert.True(t, found)
assert.Equal(t, "abc", val)

details := c.Details()
assert.NotNil(t, details.Req)
assert.NotNil(t, details.Resp)
assert.NotNil(t, details.OtherResp)

assert.Equal(t, http.StatusAccepted, details.Resp.StatusCode)
assert.Equal(t, http.StatusConflict, details.OtherResp.StatusCode)

assert.Equal(t, 1, details.Attempt)
assert.Empty(t, details.RetryDelays)
}

func TestNewClient_failedExpectation(t *testing.T) {
Expand Down

0 comments on commit 9020830

Please sign in to comment.