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

Function TestValueBinder_Float64s

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

Source from the content-addressed store, hash-verified

1498}
1499
1500func TestValueBinder_Float64s(t *testing.T) {
1501 var testCases = []struct {
1502 name string
1503 whenURL string
1504 expectError string
1505 givenBindErrors []error
1506 expectValue []float64
1507 givenFailFast bool
1508 whenMust bool
1509 }{
1510 {
1511 name: "ok, binds value",
1512 whenURL: "/search?param=4.3&param=0",
1513 expectValue: []float64{4.3, 0},
1514 },
1515 {
1516 name: "ok, params values empty, value is not changed",
1517 whenURL: "/search?nope=1",
1518 expectValue: []float64(nil),
1519 },
1520 {
1521 name: "nok, previous errors fail fast without binding value",
1522 givenFailFast: true,
1523 givenBindErrors: []error{errors.New("previous error")},
1524 whenURL: "/search?param=1&param=100",
1525 expectValue: []float64(nil),
1526 expectError: "previous error",
1527 },
1528 {
1529 name: "nok, conversion fails, value is not changed",
1530 whenURL: "/search?param=nope&param=100",
1531 expectValue: []float64(nil),
1532 expectError: "code=400, message=failed to bind field value to float64, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1533 },
1534 {
1535 name: "nok, conversion fails fast, value is not changed",
1536 givenFailFast: true,
1537 whenURL: "/search?param=0&param=nope&param=100",
1538 expectValue: []float64(nil),
1539 expectError: "code=400, message=failed to bind field value to float64, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1540 },
1541 {
1542 name: "ok (must), binds value",
1543 whenMust: true,
1544 whenURL: "/search?param=4.3&param=0",
1545 expectValue: []float64{4.3, 0},
1546 },
1547 {
1548 name: "ok (must), params values empty, returns error, value is not changed",
1549 whenMust: true,
1550 whenURL: "/search?nope=1",
1551 expectValue: []float64(nil),
1552 expectError: "code=400, message=required field value is empty, field=param",
1553 },
1554 {
1555 name: "nok (must), previous errors fail fast without binding value",
1556 givenFailFast: true,
1557 givenBindErrors: []error{errors.New("previous error")},

Callers

nothing calls this directly

Calls 6

createTestContextFunction · 0.85
QueryParamsBinderFunction · 0.85
FailFastMethod · 0.80
BindErrorMethod · 0.80
MustFloat64sMethod · 0.80
Float64sMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…