(t *testing.T)
| 672 | } |
| 673 | |
| 674 | func TestValueBinder_Uint64_uintValue(t *testing.T) { |
| 675 | var testCases = []struct { |
| 676 | name string |
| 677 | whenURL string |
| 678 | expectError string |
| 679 | givenBindErrors []error |
| 680 | expectValue uint64 |
| 681 | givenFailFast bool |
| 682 | whenMust bool |
| 683 | }{ |
| 684 | { |
| 685 | name: "ok, binds value", |
| 686 | whenURL: "/search?param=1¶m=100", |
| 687 | expectValue: 1, |
| 688 | }, |
| 689 | { |
| 690 | name: "ok, params values empty, value is not changed", |
| 691 | whenURL: "/search?nope=1", |
| 692 | expectValue: 99, |
| 693 | }, |
| 694 | { |
| 695 | name: "nok, previous errors fail fast without binding value", |
| 696 | givenFailFast: true, |
| 697 | whenURL: "/search?param=1¶m=100", |
| 698 | expectValue: 99, |
| 699 | expectError: "previous error", |
| 700 | }, |
| 701 | { |
| 702 | name: "nok, conversion fails, value is not changed", |
| 703 | whenURL: "/search?param=nope¶m=100", |
| 704 | expectValue: 99, |
| 705 | expectError: "code=400, message=failed to bind field value to uint64, err=strconv.ParseUint: parsing \"nope\": invalid syntax, field=param", |
| 706 | }, |
| 707 | { |
| 708 | name: "ok (must), binds value", |
| 709 | whenMust: true, |
| 710 | whenURL: "/search?param=1¶m=100", |
| 711 | expectValue: 1, |
| 712 | }, |
| 713 | { |
| 714 | name: "ok (must), params values empty, returns error, value is not changed", |
| 715 | whenMust: true, |
| 716 | whenURL: "/search?nope=1", |
| 717 | expectValue: 99, |
| 718 | expectError: "code=400, message=required field value is empty, field=param", |
| 719 | }, |
| 720 | { |
| 721 | name: "nok (must), previous errors fail fast without binding value", |
| 722 | givenFailFast: true, |
| 723 | whenMust: true, |
| 724 | whenURL: "/search?param=1¶m=100", |
| 725 | expectValue: 99, |
| 726 | expectError: "previous error", |
| 727 | }, |
| 728 | { |
| 729 | name: "nok (must), conversion fails, value is not changed", |
| 730 | whenMust: true, |
| 731 | whenURL: "/search?param=nope¶m=100", |
nothing calls this directly
no test coverage detected
searching dependent graphs…