(t *testing.T)
| 288 | } |
| 289 | |
| 290 | func TestShouldBindUri(t *testing.T) { |
| 291 | DefaultWriter = os.Stdout |
| 292 | router := New() |
| 293 | |
| 294 | type Person struct { |
| 295 | Name string `uri:"name" binding:"required"` |
| 296 | ID string `uri:"id" binding:"required"` |
| 297 | } |
| 298 | router.Handle(http.MethodGet, "/rest/:name/:id", func(c *Context) { |
| 299 | var person Person |
| 300 | require.NoError(t, c.ShouldBindUri(&person)) |
| 301 | assert.NotEmpty(t, person.Name) |
| 302 | assert.NotEmpty(t, person.ID) |
| 303 | c.String(http.StatusOK, "ShouldBindUri test OK") |
| 304 | }) |
| 305 | |
| 306 | path, _ := exampleFromPath("/rest/:name/:id") |
| 307 | w := PerformRequest(router, http.MethodGet, path) |
| 308 | assert.Equal(t, "ShouldBindUri test OK", w.Body.String()) |
| 309 | assert.Equal(t, http.StatusOK, w.Code) |
| 310 | } |
| 311 | |
| 312 | func TestBindUri(t *testing.T) { |
| 313 | DefaultWriter = os.Stdout |
nothing calls this directly
no test coverage detected