diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-08-10 15:05:15 +0200 | 
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-08-10 15:05:15 +0200 | 
| commit | 825e92f34920934f09dbf4c614dbd2913ba464cb (patch) | |
| tree | 2af4eb446f544e17f65b34ad2b9668d2bb8ab78b /src/pkg/http/fs_test.go | |
| parent | e6b380032482808aee5e4c5222b6d7390f468e74 (diff) | |
| download | golang-825e92f34920934f09dbf4c614dbd2913ba464cb.tar.gz | |
Imported Upstream version 2011.08.10upstream-weekly/2011.08.10
Diffstat (limited to 'src/pkg/http/fs_test.go')
| -rw-r--r-- | src/pkg/http/fs_test.go | 25 | 
1 files changed, 23 insertions, 2 deletions
| diff --git a/src/pkg/http/fs_test.go b/src/pkg/http/fs_test.go index 4d465d89a..823770ec4 100644 --- a/src/pkg/http/fs_test.go +++ b/src/pkg/http/fs_test.go @@ -223,7 +223,7 @@ func TestServeFileContentType(t *testing.T) {  			t.Fatal(err)  		}  		if h := resp.Header.Get("Content-Type"); h != want { -			t.Errorf("Content-Type mismatch: got %d, want %d", h, want) +			t.Errorf("Content-Type mismatch: got %q, want %q", h, want)  		}  	}  	get("text/plain; charset=utf-8") @@ -257,7 +257,28 @@ func TestServeFileWithContentEncoding(t *testing.T) {  		t.Fatal(err)  	}  	if g, e := resp.ContentLength, int64(-1); g != e { -		t.Errorf("Content-Length mismatch: got %q, want %q", g, e) +		t.Errorf("Content-Length mismatch: got %d, want %d", g, e) +	} +} + +func TestServeIndexHtml(t *testing.T) { +	const want = "index.html says hello\n" +	ts := httptest.NewServer(FileServer(Dir("."))) +	defer ts.Close() + +	for _, path := range []string{"/testdata/", "/testdata/index.html"} { +		res, err := Get(ts.URL + path) +		if err != nil { +			t.Fatal(err) +		} +		defer res.Body.Close() +		b, err := ioutil.ReadAll(res.Body) +		if err != nil { +			t.Fatal("reading Body:", err) +		} +		if s := string(b); s != want { +			t.Errorf("for path %q got %q, want %q", path, s, want) +		}  	}  } | 
