(t *testing.T)
| 2520 | } |
| 2521 | |
| 2522 | func TestValueBinder_BindWithDelimiter(t *testing.T) { |
| 2523 | var testCases = []struct { |
| 2524 | name string |
| 2525 | whenURL string |
| 2526 | expectError string |
| 2527 | givenBindErrors []error |
| 2528 | expectValue []int64 |
| 2529 | givenFailFast bool |
| 2530 | whenMust bool |
| 2531 | }{ |
| 2532 | { |
| 2533 | name: "ok, binds value", |
| 2534 | whenURL: "/search?param=1,2¶m=1", |
| 2535 | expectValue: []int64{1, 2, 1}, |
| 2536 | }, |
| 2537 | { |
| 2538 | name: "ok, params values empty, value is not changed", |
| 2539 | whenURL: "/search?nope=1", |
| 2540 | expectValue: []int64(nil), |
| 2541 | }, |
| 2542 | { |
| 2543 | name: "nok, previous errors fail fast without binding value", |
| 2544 | givenFailFast: true, |
| 2545 | whenURL: "/search?param=1¶m=100", |
| 2546 | expectValue: []int64(nil), |
| 2547 | expectError: "previous error", |
| 2548 | }, |
| 2549 | { |
| 2550 | name: "nok, conversion fails, value is not changed", |
| 2551 | whenURL: "/search?param=nope¶m=100", |
| 2552 | expectValue: []int64(nil), |
| 2553 | expectError: "code=400, message=failed to bind field value to int64, err=strconv.ParseInt: parsing \"nope\": invalid syntax, field=param", |
| 2554 | }, |
| 2555 | { |
| 2556 | name: "ok (must), binds value", |
| 2557 | whenMust: true, |
| 2558 | whenURL: "/search?param=1,2¶m=1", |
| 2559 | expectValue: []int64{1, 2, 1}, |
| 2560 | }, |
| 2561 | { |
| 2562 | name: "ok (must), params values empty, returns error, value is not changed", |
| 2563 | whenMust: true, |
| 2564 | whenURL: "/search?nope=1", |
| 2565 | expectValue: []int64(nil), |
| 2566 | expectError: "code=400, message=required field value is empty, field=param", |
| 2567 | }, |
| 2568 | { |
| 2569 | name: "nok (must), previous errors fail fast without binding value", |
| 2570 | givenFailFast: true, |
| 2571 | whenMust: true, |
| 2572 | whenURL: "/search?param=1¶m=100", |
| 2573 | expectValue: []int64(nil), |
| 2574 | expectError: "previous error", |
| 2575 | }, |
| 2576 | { |
| 2577 | name: "nok (must), conversion fails, value is not changed", |
| 2578 | whenMust: true, |
| 2579 | whenURL: "/search?param=nope¶m=100", |
nothing calls this directly
no test coverage detected
searching dependent graphs…