~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/net/http/sniff_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
}
55
55
 
56
56
func TestServerContentType(t *testing.T) {
 
57
        defer afterTest(t)
57
58
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
58
59
                i, _ := strconv.Atoi(r.FormValue("i"))
59
60
                tt := sniffTests[i]
84
85
}
85
86
 
86
87
func TestContentTypeWithCopy(t *testing.T) {
 
88
        defer afterTest(t)
 
89
 
87
90
        const (
88
91
                input    = "\n<html>\n\t<head>\n"
89
92
                expected = "text/html; charset=utf-8"
116
119
}
117
120
 
118
121
func TestSniffWriteSize(t *testing.T) {
 
122
        defer afterTest(t)
119
123
        ts := httptest.NewServer(HandlerFunc(func(w ResponseWriter, r *Request) {
120
124
                size, _ := strconv.Atoi(r.FormValue("size"))
121
125
                written, err := io.WriteString(w, strings.Repeat("a", size))
133
137
                if err != nil {
134
138
                        t.Fatalf("size %d: %v", size, err)
135
139
                }
136
 
                res.Body.Close()
 
140
                if _, err := io.Copy(ioutil.Discard, res.Body); err != nil {
 
141
                        t.Fatalf("size %d: io.Copy of body = %v", size, err)
 
142
                }
 
143
                if err := res.Body.Close(); err != nil {
 
144
                        t.Fatalf("size %d: body Close = %v", size, err)
 
145
                }
137
146
        }
138
147
}