(t *testing.T)
| 127 | } |
| 128 | |
| 129 | func TestFakeHandlerWrongBody(t *testing.T) { |
| 130 | handler := FakeHandler{StatusCode: http.StatusOK} |
| 131 | server := httptest.NewServer(&handler) |
| 132 | defer server.Close() |
| 133 | method := "GET" |
| 134 | path := "/foo/bar" |
| 135 | body := "somebody" |
| 136 | fakeT := fakeError{} |
| 137 | |
| 138 | req, err := http.NewRequest(method, server.URL+path, bytes.NewBufferString(body)) |
| 139 | if err != nil { |
| 140 | t.Errorf("unexpected error: %v", err) |
| 141 | } |
| 142 | |
| 143 | client := http.Client{} |
| 144 | _, err = client.Do(req) |
| 145 | if err != nil { |
| 146 | t.Errorf("unexpected error: %v", err) |
| 147 | } |
| 148 | |
| 149 | otherbody := "otherbody" |
| 150 | handler.ValidateRequest(&fakeT, path, method, &otherbody) |
| 151 | if len(fakeT.errors) != 1 { |
| 152 | t.Errorf("Unexpected error set: %#v", fakeT.errors) |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func TestFakeHandlerNilBody(t *testing.T) { |
| 157 | handler := FakeHandler{StatusCode: http.StatusOK} |
nothing calls this directly
no test coverage detected