MCPcopy
hub / github.com/labstack/echo / createTestContext

Function createTestContext

binder_test.go:21–42  ·  view source on GitHub ↗
(URL string, body io.Reader, pathValues map[string]string)

Source from the content-addressed store, hash-verified

19)
20
21func 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
44func TestBindingError_Error(t *testing.T) {
45 err := NewBindingError("id", []string{"1", "nope"}, "bind failed", errors.New("internal error"))

Calls 4

SetPathValuesMethod · 0.95
NewFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…