(t *testing.T)
| 175 | } |
| 176 | |
| 177 | func TestToMultipleFields(t *testing.T) { |
| 178 | e := New() |
| 179 | req := httptest.NewRequest(http.MethodGet, "/?id=1&ID=2", nil) |
| 180 | rec := httptest.NewRecorder() |
| 181 | c := e.NewContext(req, rec) |
| 182 | |
| 183 | type Root struct { |
| 184 | ID int64 `query:"id"` |
| 185 | Child2 struct { |
| 186 | ID int64 |
| 187 | } |
| 188 | Child1 struct { |
| 189 | ID int64 `query:"id"` |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | u := new(Root) |
| 194 | err := c.Bind(u) |
| 195 | if assert.NoError(t, err) { |
| 196 | assert.Equal(t, int64(1), u.ID) // perfectly reasonable |
| 197 | assert.Equal(t, int64(1), u.Child1.ID) // untagged struct containing tagged field gets filled (by tag) |
| 198 | assert.Equal(t, int64(0), u.Child2.ID) // untagged struct containing untagged field should not be bind |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | func TestBindJSON(t *testing.T) { |
| 203 | testBindOkay(t, strings.NewReader(userJSON), nil, MIMEApplicationJSON) |
nothing calls this directly
no test coverage detected
searching dependent graphs…