From 2ebf0de27c8f12517323d8fd57ac99d213259681 Mon Sep 17 00:00:00 2001 From: David Symonds Date: Wed, 18 Jan 2012 08:28:09 +1100 Subject: [PATCH] net/http: change test to use override param instead of chan. Follow-on from https://golang.org/cl/5543062. R=bradfitz, dvyukov CC=golang-dev https://golang.org/cl/5539071 --- src/pkg/net/http/fs_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/pkg/net/http/fs_test.go b/src/pkg/net/http/fs_test.go index 8abd337cad..85cad3ec71 100644 --- a/src/pkg/net/http/fs_test.go +++ b/src/pkg/net/http/fs_test.go @@ -224,16 +224,15 @@ func TestEmptyDirOpenCWD(t *testing.T) { func TestServeFileContentType(t *testing.T) { const ctype = "icecream/chocolate" - override := make(chan bool, 1) ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) { - if <-override { + if r.FormValue("override") == "1" { w.Header().Set("Content-Type", ctype) } ServeFile(w, r, "testdata/file") })) defer ts.Close() - get := func(want string) { - resp, err := Get(ts.URL) + get := func(override, want string) { + resp, err := Get(ts.URL + "?override=" + override) if err != nil { t.Fatal(err) } @@ -241,10 +240,8 @@ func TestServeFileContentType(t *testing.T) { t.Errorf("Content-Type mismatch: got %q, want %q", h, want) } } - override <- false - get("text/plain; charset=utf-8") - override <- true - get(ctype) + get("0", "text/plain; charset=utf-8") + get("1", ctype) } func TestServeFileMimeType(t *testing.T) {