(t *testing.T)
| 307 | } |
| 308 | |
| 309 | func TestBindUnmarshalParam(t *testing.T) { |
| 310 | e := New() |
| 311 | req := httptest.NewRequest(http.MethodGet, "/?ts=2016-12-06T19:09:05Z&sa=one,two,three&ta=2016-12-06T19:09:05Z&ta=2016-12-06T19:09:05Z&ST=baz", nil) |
| 312 | rec := httptest.NewRecorder() |
| 313 | c := e.NewContext(req, rec) |
| 314 | result := struct { |
| 315 | T Timestamp `query:"ts"` |
| 316 | ST Struct |
| 317 | StWithTag struct { |
| 318 | Foo string `query:"st"` |
| 319 | } |
| 320 | TA []Timestamp `query:"ta"` |
| 321 | SA StringArray `query:"sa"` |
| 322 | }{} |
| 323 | err := c.Bind(&result) |
| 324 | ts := Timestamp(time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)) |
| 325 | |
| 326 | if assert.NoError(t, err) { |
| 327 | // assert.Equal( Timestamp(reflect.TypeOf(&Timestamp{}), time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)), result.T) |
| 328 | assert.Equal(t, ts, result.T) |
| 329 | assert.Equal(t, StringArray([]string{"one", "two", "three"}), result.SA) |
| 330 | assert.Equal(t, []Timestamp{ts, ts}, result.TA) |
| 331 | assert.Equal(t, Struct{""}, result.ST) // child struct does not have a field with matching tag |
| 332 | assert.Equal(t, "baz", result.StWithTag.Foo) // child struct has field with matching tag |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | func TestBindUnmarshalText(t *testing.T) { |
| 337 | e := New() |
nothing calls this directly
no test coverage detected
searching dependent graphs…