Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / libgo / go / http / client_test.go
blob013653a829695d63dd48b0da3ba94aad4b438c92
1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Tests for client.go
7 package http
9 import (
10 "io/ioutil"
11 "strings"
12 "testing"
15 func TestClient(t *testing.T) {
16 // TODO: add a proper test suite. Current test merely verifies that
17 // we can retrieve the Google robots.txt file.
19 r, _, err := Get("http://www.google.com/robots.txt")
20 var b []byte
21 if err == nil {
22 b, err = ioutil.ReadAll(r.Body)
23 r.Body.Close()
25 if err != nil {
26 t.Error(err)
27 } else if s := string(b); !strings.HasPrefix(s, "User-agent:") {
28 t.Errorf("Incorrect page body (did not begin with User-agent): %q", s)
32 func TestClientHead(t *testing.T) {
33 r, err := Head("http://www.google.com/robots.txt")
34 if err != nil {
35 t.Fatal(err)
37 if _, ok := r.Header["Last-Modified"]; !ok {
38 t.Error("Last-Modified header not found.")