summaryrefslogtreecommitdiffstats
path: root/client/go/internal/mock/http.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/go/internal/mock/http.go')
-rw-r--r--client/go/internal/mock/http.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/client/go/internal/mock/http.go b/client/go/internal/mock/http.go
index 2fbaa85ecca..8274f4113d3 100644
--- a/client/go/internal/mock/http.go
+++ b/client/go/internal/mock/http.go
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
+ "os"
"strconv"
"time"
)
@@ -17,6 +18,9 @@ type HTTPClient struct {
// The errors to return for future requests. If non-nil, these errors are returned before any responses in nextResponses.
nextErrors []error
+ // LogRequests enables logging of all requests made through this client.
+ LogRequests bool
+
// LastRequest is the last HTTP request made through this.
LastRequest *http.Request
@@ -56,7 +60,12 @@ func (c *HTTPClient) NextResponseError(err error) {
c.nextErrors = append(c.nextErrors, err)
}
+func (c *HTTPClient) Consumed() bool { return len(c.nextResponses) == 0 }
+
func (c *HTTPClient) Do(request *http.Request, timeout time.Duration) (*http.Response, error) {
+ if c.LogRequests {
+ fmt.Fprintf(os.Stderr, "Sending request %+v\n", request)
+ }
c.LastRequest = request
if len(c.nextErrors) > 0 {
err := c.nextErrors[0]