@@ -293,12 +293,20 @@ func TestSplitParameter(t *testing.T) {
293293
294294func TestBindQueryParameter (t * testing.T ) {
295295 t .Run ("deepObject" , func (t * testing.T ) {
296+ type Object struct {
297+ Count int `json:"count"`
298+ }
299+ type Nested struct {
300+ Object Object `json:"object"`
301+ Objects []Object `json:"objects"`
302+ }
296303 type ID struct {
297304 FirstName * string `json:"firstName"`
298305 LastName * string `json:"lastName"`
299306 Role string `json:"role"`
300307 Birthday * types.Date `json:"birthday"`
301308 Married * MockBinder `json:"married"`
309+ Nested Nested `json:"nested"`
302310 }
303311
304312 expectedName := "Alex"
@@ -307,16 +315,23 @@ func TestBindQueryParameter(t *testing.T) {
307315 Role : "admin" ,
308316 Birthday : & types.Date {Time : time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )},
309317 Married : & MockBinder {time .Date (2020 , 2 , 2 , 0 , 0 , 0 , 0 , time .UTC )},
318+ Nested : Nested {
319+ Object : Object {Count : 123 },
320+ Objects : []Object {{Count : 1 }, {Count : 2 }},
321+ },
310322 }
311323
312324 actual := new (ID )
313325 paramName := "id"
314326 queryParams := url.Values {
315- "id[firstName]" : {"Alex" },
316- "id[role]" : {"admin" },
317- "foo" : {"bar" },
318- "id[birthday]" : {"2020-01-01" },
319- "id[married]" : {"2020-02-02" },
327+ "id[firstName]" : {"Alex" },
328+ "id[role]" : {"admin" },
329+ "foo" : {"bar" },
330+ "id[birthday]" : {"2020-01-01" },
331+ "id[married]" : {"2020-02-02" },
332+ "id[nested][object][count]" : {"123" },
333+ "id[nested][objects][0][count]" : {"1" },
334+ "id[nested][objects][1][count]" : {"2" },
320335 }
321336
322337 err := BindQueryParameter ("deepObject" , true , false , paramName , queryParams , & actual )
@@ -356,7 +371,6 @@ func TestBindQueryParameter(t *testing.T) {
356371 assert .Error (t , err )
357372 err = BindQueryParameter ("form" , true , true , "notfound" , queryParams , & optionalNumber )
358373 assert .Error (t , err )
359-
360374 })
361375}
362376
0 commit comments