MCPcopy
hub / github.com/labstack/echo / TestValueBinder_errorStopsBinding

Function TestValueBinder_errorStopsBinding

binder_test.go:167–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func 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
185func TestValueBinder_BindError(t *testing.T) {
186 c := createTestContext("/api/user/999?nr=en&id=nope", nil, nil)

Callers

nothing calls this directly

Calls 4

createTestContextFunction · 0.85
QueryParamsBinderFunction · 0.85
BindErrorMethod · 0.80
Int64Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…