(t *testing.T)
| 1594 | } |
| 1595 | |
| 1596 | func TestValueBinder_Float32(t *testing.T) { |
| 1597 | var testCases = []struct { |
| 1598 | name string |
| 1599 | whenURL string |
| 1600 | expectError string |
| 1601 | givenBindErrors []error |
| 1602 | expectValue float32 |
| 1603 | givenNoFailFast bool |
| 1604 | whenMust bool |
| 1605 | }{ |
| 1606 | { |
| 1607 | name: "ok, binds value", |
| 1608 | whenURL: "/search?param=4.3¶m=1", |
| 1609 | expectValue: 4.3, |
| 1610 | }, |
| 1611 | { |
| 1612 | name: "ok, params values empty, value is not changed", |
| 1613 | whenURL: "/search?nope=1", |
| 1614 | expectValue: 1.123, |
| 1615 | }, |
| 1616 | { |
| 1617 | name: "nok, previous errors fail fast without binding value", |
| 1618 | givenNoFailFast: true, |
| 1619 | whenURL: "/search?param=1¶m=100", |
| 1620 | expectValue: 1.123, |
| 1621 | expectError: "previous error", |
| 1622 | }, |
| 1623 | { |
| 1624 | name: "nok, conversion fails, value is not changed", |
| 1625 | whenURL: "/search?param=nope¶m=100", |
| 1626 | expectValue: 1.123, |
| 1627 | expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param", |
| 1628 | }, |
| 1629 | { |
| 1630 | name: "ok (must), binds value", |
| 1631 | whenMust: true, |
| 1632 | whenURL: "/search?param=4.3¶m=100", |
| 1633 | expectValue: 4.3, |
| 1634 | }, |
| 1635 | { |
| 1636 | name: "ok (must), params values empty, returns error, value is not changed", |
| 1637 | whenMust: true, |
| 1638 | whenURL: "/search?nope=1", |
| 1639 | expectValue: 1.123, |
| 1640 | expectError: "code=400, message=required field value is empty, field=param", |
| 1641 | }, |
| 1642 | { |
| 1643 | name: "nok (must), previous errors fail fast without binding value", |
| 1644 | givenNoFailFast: true, |
| 1645 | whenMust: true, |
| 1646 | whenURL: "/search?param=1¶m=100", |
| 1647 | expectValue: 1.123, |
| 1648 | expectError: "previous error", |
| 1649 | }, |
| 1650 | { |
| 1651 | name: "nok (must), conversion fails, value is not changed", |
| 1652 | whenMust: true, |
| 1653 | whenURL: "/search?param=nope¶m=100", |
nothing calls this directly
no test coverage detected
searching dependent graphs…