(t *testing.T)
| 568 | } |
| 569 | |
| 570 | func TestValueBinder_Int64_intValue(t *testing.T) { |
| 571 | var testCases = []struct { |
| 572 | name string |
| 573 | whenURL string |
| 574 | expectError string |
| 575 | givenBindErrors []error |
| 576 | expectValue int64 |
| 577 | givenFailFast bool |
| 578 | whenMust bool |
| 579 | }{ |
| 580 | { |
| 581 | name: "ok, binds value", |
| 582 | whenURL: "/search?param=1¶m=100", |
| 583 | expectValue: 1, |
| 584 | }, |
| 585 | { |
| 586 | name: "ok, params values empty, value is not changed", |
| 587 | whenURL: "/search?nope=1", |
| 588 | expectValue: 99, |
| 589 | }, |
| 590 | { |
| 591 | name: "nok, previous errors fail fast without binding value", |
| 592 | givenFailFast: true, |
| 593 | whenURL: "/search?param=1¶m=100", |
| 594 | expectValue: 99, |
| 595 | expectError: "previous error", |
| 596 | }, |
| 597 | { |
| 598 | name: "nok, conversion fails, value is not changed", |
| 599 | whenURL: "/search?param=nope¶m=100", |
| 600 | expectValue: 99, |
| 601 | expectError: "code=400, message=failed to bind field value to int64, err=strconv.ParseInt: parsing \"nope\": invalid syntax, field=param", |
| 602 | }, |
| 603 | { |
| 604 | name: "ok (must), binds value", |
| 605 | whenMust: true, |
| 606 | whenURL: "/search?param=1¶m=100", |
| 607 | expectValue: 1, |
| 608 | }, |
| 609 | { |
| 610 | name: "ok (must), params values empty, returns error, value is not changed", |
| 611 | whenMust: true, |
| 612 | whenURL: "/search?nope=1", |
| 613 | expectValue: 99, |
| 614 | expectError: "code=400, message=required field value is empty, field=param", |
| 615 | }, |
| 616 | { |
| 617 | name: "nok (must), previous errors fail fast without binding value", |
| 618 | givenFailFast: true, |
| 619 | whenMust: true, |
| 620 | whenURL: "/search?param=1¶m=100", |
| 621 | expectValue: 99, |
| 622 | expectError: "previous error", |
| 623 | }, |
| 624 | { |
| 625 | name: "nok (must), conversion fails, value is not changed", |
| 626 | whenMust: true, |
| 627 | whenURL: "/search?param=nope¶m=100", |
nothing calls this directly
no test coverage detected
searching dependent graphs…