(t *testing.T)
| 165 | } |
| 166 | |
| 167 | func TestValueBinder_errorStopsBinding(t *testing.T) { |
| 168 | // this test documents "feature" that binding multiple params can change destination if it was bound before |
| 169 | // failing parameter binding |
| 170 | |
| 171 | c := createTestContext("/api/user/999?id=1&nr=nope", nil, nil) |
| 172 | b := QueryParamsBinder(c) |
| 173 | |
| 174 | id := int64(99) // will be changed before nr binding fails |
| 175 | nr := int64(88) // will not be changed |
| 176 | err := b.Int64("id", &id). |
| 177 | Int64("nr", &nr). |
| 178 | BindError() |
| 179 | |
| 180 | assert.EqualError(t, err, "code=400, message=failed to bind field value to int64, err=strconv.ParseInt: parsing \"nope\": invalid syntax, field=nr") |
| 181 | assert.Equal(t, int64(1), id) |
| 182 | assert.Equal(t, int64(88), nr) |
| 183 | } |
| 184 | |
| 185 | func TestValueBinder_BindError(t *testing.T) { |
| 186 | c := createTestContext("/api/user/999?nr=en&id=nope", nil, nil) |
nothing calls this directly
no test coverage detected
searching dependent graphs…