(t *testing.T)
| 1683 | } |
| 1684 | |
| 1685 | func TestValueBinder_Float32s(t *testing.T) { |
| 1686 | var testCases = []struct { |
| 1687 | name string |
| 1688 | whenURL string |
| 1689 | expectError string |
| 1690 | givenBindErrors []error |
| 1691 | expectValue []float32 |
| 1692 | givenFailFast bool |
| 1693 | whenMust bool |
| 1694 | }{ |
| 1695 | { |
| 1696 | name: "ok, binds value", |
| 1697 | whenURL: "/search?param=4.3¶m=0", |
| 1698 | expectValue: []float32{4.3, 0}, |
| 1699 | }, |
| 1700 | { |
| 1701 | name: "ok, params values empty, value is not changed", |
| 1702 | whenURL: "/search?nope=1", |
| 1703 | expectValue: []float32(nil), |
| 1704 | }, |
| 1705 | { |
| 1706 | name: "nok, previous errors fail fast without binding value", |
| 1707 | givenFailFast: true, |
| 1708 | givenBindErrors: []error{errors.New("previous error")}, |
| 1709 | whenURL: "/search?param=1¶m=100", |
| 1710 | expectValue: []float32(nil), |
| 1711 | expectError: "previous error", |
| 1712 | }, |
| 1713 | { |
| 1714 | name: "nok, conversion fails, value is not changed", |
| 1715 | whenURL: "/search?param=nope¶m=100", |
| 1716 | expectValue: []float32(nil), |
| 1717 | expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param", |
| 1718 | }, |
| 1719 | { |
| 1720 | name: "nok, conversion fails fast, value is not changed", |
| 1721 | givenFailFast: true, |
| 1722 | whenURL: "/search?param=0¶m=nope¶m=100", |
| 1723 | expectValue: []float32(nil), |
| 1724 | expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param", |
| 1725 | }, |
| 1726 | { |
| 1727 | name: "ok (must), binds value", |
| 1728 | whenMust: true, |
| 1729 | whenURL: "/search?param=4.3¶m=0", |
| 1730 | expectValue: []float32{4.3, 0}, |
| 1731 | }, |
| 1732 | { |
| 1733 | name: "ok (must), params values empty, returns error, value is not changed", |
| 1734 | whenMust: true, |
| 1735 | whenURL: "/search?nope=1", |
| 1736 | expectValue: []float32(nil), |
| 1737 | expectError: "code=400, message=required field value is empty, field=param", |
| 1738 | }, |
| 1739 | { |
| 1740 | name: "nok (must), previous errors fail fast without binding value", |
| 1741 | givenFailFast: true, |
| 1742 | givenBindErrors: []error{errors.New("previous error")}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…