MCPcopy Index your code
hub / github.com/labstack/echo / TestValueBinder_Float64

Function TestValueBinder_Float64

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

Source from the content-addressed store, hash-verified

1409}
1410
1411func TestValueBinder_Float64(t *testing.T) {
1412 var testCases = []struct {
1413 name string
1414 whenURL string
1415 expectError string
1416 givenBindErrors []error
1417 expectValue float64
1418 givenFailFast bool
1419 whenMust bool
1420 }{
1421 {
1422 name: "ok, binds value",
1423 whenURL: "/search?param=4.3&param=1",
1424 expectValue: 4.3,
1425 },
1426 {
1427 name: "ok, params values empty, value is not changed",
1428 whenURL: "/search?nope=1",
1429 expectValue: 1.123,
1430 },
1431 {
1432 name: "nok, previous errors fail fast without binding value",
1433 givenFailFast: true,
1434 whenURL: "/search?param=1&param=100",
1435 expectValue: 1.123,
1436 expectError: "previous error",
1437 },
1438 {
1439 name: "nok, conversion fails, value is not changed",
1440 whenURL: "/search?param=nope&param=100",
1441 expectValue: 1.123,
1442 expectError: "code=400, message=failed to bind field value to float64, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1443 },
1444 {
1445 name: "ok (must), binds value",
1446 whenMust: true,
1447 whenURL: "/search?param=4.3&param=100",
1448 expectValue: 4.3,
1449 },
1450 {
1451 name: "ok (must), params values empty, returns error, value is not changed",
1452 whenMust: true,
1453 whenURL: "/search?nope=1",
1454 expectValue: 1.123,
1455 expectError: "code=400, message=required field value is empty, field=param",
1456 },
1457 {
1458 name: "nok (must), previous errors fail fast without binding value",
1459 givenFailFast: true,
1460 whenMust: true,
1461 whenURL: "/search?param=1&param=100",
1462 expectValue: 1.123,
1463 expectError: "previous error",
1464 },
1465 {
1466 name: "nok (must), conversion fails, value is not changed",
1467 whenMust: true,
1468 whenURL: "/search?param=nope&param=100",

Callers

nothing calls this directly

Calls 6

createTestContextFunction · 0.85
QueryParamsBinderFunction · 0.85
FailFastMethod · 0.80
BindErrorMethod · 0.80
MustFloat64Method · 0.80
Float64Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…