summaryrefslogtreecommitdiff
path: root/libgo/go/http/client_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/http/client_test.go')
-rw-r--r--libgo/go/http/client_test.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libgo/go/http/client_test.go b/libgo/go/http/client_test.go
index 013653a8296..c89ecbce2d0 100644
--- a/libgo/go/http/client_test.go
+++ b/libgo/go/http/client_test.go
@@ -8,6 +8,7 @@ package http
import (
"io/ioutil"
+ "os"
"strings"
"testing"
)
@@ -38,3 +39,28 @@ func TestClientHead(t *testing.T) {
t.Error("Last-Modified header not found.")
}
}
+
+type recordingTransport struct {
+ req *Request
+}
+
+func (t *recordingTransport) Do(req *Request) (resp *Response, err os.Error) {
+ t.req = req
+ return nil, os.NewError("dummy impl")
+}
+
+func TestGetRequestFormat(t *testing.T) {
+ tr := &recordingTransport{}
+ client := &Client{Transport: tr}
+ url := "http://dummy.faketld/"
+ client.Get(url) // Note: doesn't hit network
+ if tr.req.Method != "GET" {
+ t.Errorf("expected method %q; got %q", "GET", tr.req.Method)
+ }
+ if tr.req.URL.String() != url {
+ t.Errorf("expected URL %q; got %q", url, tr.req.URL.String())
+ }
+ if tr.req.Header == nil {
+ t.Errorf("expected non-nil request Header")
+ }
+}