(t *testing.T)
| 38 | } |
| 39 | |
| 40 | func TestWrap(t *testing.T) { |
| 41 | router := New() |
| 42 | router.POST("/path", WrapH(&testStruct{t})) |
| 43 | router.GET("/path2", WrapF(func(w http.ResponseWriter, req *http.Request) { |
| 44 | assert.Equal(t, http.MethodGet, req.Method) |
| 45 | assert.Equal(t, "/path2", req.URL.Path) |
| 46 | w.WriteHeader(http.StatusBadRequest) |
| 47 | fmt.Fprint(w, "hola!") |
| 48 | })) |
| 49 | |
| 50 | w := PerformRequest(router, http.MethodPost, "/path") |
| 51 | assert.Equal(t, http.StatusInternalServerError, w.Code) |
| 52 | assert.Equal(t, "hello", w.Body.String()) |
| 53 | |
| 54 | w = PerformRequest(router, http.MethodGet, "/path2") |
| 55 | assert.Equal(t, http.StatusBadRequest, w.Code) |
| 56 | assert.Equal(t, "hola!", w.Body.String()) |
| 57 | } |
| 58 | |
| 59 | func TestLastChar(t *testing.T) { |
| 60 | assert.Equal(t, uint8('a'), lastChar("hola")) |
nothing calls this directly
no test coverage detected