(URL string, body io.Reader, pathValues map[string]string)
| 19 | ) |
| 20 | |
| 21 | func createTestContext(URL string, body io.Reader, pathValues map[string]string) *Context { |
| 22 | e := New() |
| 23 | req := httptest.NewRequest(http.MethodGet, URL, body) |
| 24 | if body != nil { |
| 25 | req.Header.Set(HeaderContentType, MIMEApplicationJSON) |
| 26 | } |
| 27 | rec := httptest.NewRecorder() |
| 28 | c := e.NewContext(req, rec) |
| 29 | |
| 30 | if len(pathValues) > 0 { |
| 31 | params := make(PathValues, 0) |
| 32 | for name, value := range pathValues { |
| 33 | params = append(params, PathValue{ |
| 34 | Name: name, |
| 35 | Value: value, |
| 36 | }) |
| 37 | } |
| 38 | c.SetPathValues(params) |
| 39 | } |
| 40 | |
| 41 | return c |
| 42 | } |
| 43 | |
| 44 | func TestBindingError_Error(t *testing.T) { |
| 45 | err := NewBindingError("id", []string{"1", "nope"}, "bind failed", errors.New("internal error")) |
no test coverage detected
searching dependent graphs…