1
0
mirror of https://github.com/golang/go synced 2024-11-13 18:50:24 -07:00

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
This commit is contained in:
David Symonds 2012-01-18 08:28:09 +11:00
parent 4985ee3dcb
commit 2ebf0de27c

View File

@ -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) {