(t *testing.T)
| 98 | } |
| 99 | |
| 100 | func TestResponseErrorHTML(t *testing.T) { |
| 101 | raw := "HTTP/1.1 413 Request Entity Too Large\r\n" + |
| 102 | "\r\n" + |
| 103 | `<html> |
| 104 | <head><title>413 Request Entity Too Large</title></head> |
| 105 | <body bgcolor="white"> |
| 106 | <center><h1>413 Request Entity Too Large</h1></center> |
| 107 | <hr><center>nginx/1.6.2</center> |
| 108 | </body> |
| 109 | </html>` + "\r\n" |
| 110 | r := bufio.NewReader(strings.NewReader(raw)) |
| 111 | |
| 112 | req, err := http.NewRequest("GET", "/", nil) |
| 113 | if err != nil { |
| 114 | t.Fatal(err) |
| 115 | } |
| 116 | |
| 117 | resp, err := http.ReadResponse(r, nil) |
| 118 | if err != nil { |
| 119 | t.Fatal(err) |
| 120 | } |
| 121 | err = checkResponse(req, resp) |
| 122 | if err == nil { |
| 123 | t.Fatalf("expected error; got: %v", err) |
| 124 | } |
| 125 | |
| 126 | // Check for correct error message |
| 127 | expected := fmt.Sprintf("elastic: Error %d (%s)", http.StatusRequestEntityTooLarge, http.StatusText(http.StatusRequestEntityTooLarge)) |
| 128 | got := err.Error() |
| 129 | if got != expected { |
| 130 | t.Fatalf("expected %q; got: %q", expected, got) |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | func TestResponseErrorWithIgnore(t *testing.T) { |
| 135 | raw := "HTTP/1.1 404 Not Found\r\n" + |
nothing calls this directly
no test coverage detected
searching dependent graphs…