| 960 | } |
| 961 | |
| 962 | func TestCustomUnmarshalStruct(t *testing.T) { |
| 963 | route := Default() |
| 964 | var request struct { |
| 965 | Birthday Birthday `form:"birthday"` |
| 966 | } |
| 967 | route.GET("/test", func(ctx *Context) { |
| 968 | _ = ctx.BindQuery(&request) |
| 969 | ctx.JSON(200, request.Birthday) |
| 970 | }) |
| 971 | req := httptest.NewRequest(http.MethodGet, "/test?birthday=2000-01-01", nil) |
| 972 | w := httptest.NewRecorder() |
| 973 | route.ServeHTTP(w, req) |
| 974 | assert.Equal(t, 200, w.Code) |
| 975 | assert.Equal(t, `"2000/01/01"`, w.Body.String()) |
| 976 | } |
| 977 | |
| 978 | // Test the fix for https://github.com/gin-gonic/gin/issues/4002 |
| 979 | func TestMethodNotAllowedNoRoute(t *testing.T) { |