(t *testing.T)
| 310 | } |
| 311 | |
| 312 | func TestBindUri(t *testing.T) { |
| 313 | DefaultWriter = os.Stdout |
| 314 | router := New() |
| 315 | |
| 316 | type Person struct { |
| 317 | Name string `uri:"name" binding:"required"` |
| 318 | ID string `uri:"id" binding:"required"` |
| 319 | } |
| 320 | router.Handle(http.MethodGet, "/rest/:name/:id", func(c *Context) { |
| 321 | var person Person |
| 322 | require.NoError(t, c.BindUri(&person)) |
| 323 | assert.NotEmpty(t, person.Name) |
| 324 | assert.NotEmpty(t, person.ID) |
| 325 | c.String(http.StatusOK, "BindUri test OK") |
| 326 | }) |
| 327 | |
| 328 | path, _ := exampleFromPath("/rest/:name/:id") |
| 329 | w := PerformRequest(router, http.MethodGet, path) |
| 330 | assert.Equal(t, "BindUri test OK", w.Body.String()) |
| 331 | assert.Equal(t, http.StatusOK, w.Code) |
| 332 | } |
| 333 | |
| 334 | func TestBindUriError(t *testing.T) { |
| 335 | DefaultWriter = os.Stdout |
nothing calls this directly
no test coverage detected