(t *testing.T)
| 968 | } |
| 969 | |
| 970 | func TestValueBinder_Uint64s_uintsValue(t *testing.T) { |
| 971 | var testCases = []struct { |
| 972 | name string |
| 973 | whenURL string |
| 974 | expectError string |
| 975 | givenBindErrors []error |
| 976 | expectValue []uint64 |
| 977 | givenFailFast bool |
| 978 | whenMust bool |
| 979 | }{ |
| 980 | { |
| 981 | name: "ok, binds value", |
| 982 | whenURL: "/search?param=1¶m=2¶m=1", |
| 983 | expectValue: []uint64{1, 2, 1}, |
| 984 | }, |
| 985 | { |
| 986 | name: "ok, params values empty, value is not changed", |
| 987 | whenURL: "/search?nope=1", |
| 988 | expectValue: []uint64{99}, |
| 989 | }, |
| 990 | { |
| 991 | name: "nok, previous errors fail fast without binding value", |
| 992 | givenFailFast: true, |
| 993 | whenURL: "/search?param=1¶m=100", |
| 994 | expectValue: []uint64{99}, |
| 995 | expectError: "previous error", |
| 996 | }, |
| 997 | { |
| 998 | name: "nok, conversion fails, value is not changed", |
| 999 | whenURL: "/search?param=nope¶m=100", |
| 1000 | expectValue: []uint64{99}, |
| 1001 | expectError: "code=400, message=failed to bind field value to uint64, err=strconv.ParseUint: parsing \"nope\": invalid syntax, field=param", |
| 1002 | }, |
| 1003 | { |
| 1004 | name: "ok (must), binds value", |
| 1005 | whenMust: true, |
| 1006 | whenURL: "/search?param=1¶m=2¶m=1", |
| 1007 | expectValue: []uint64{1, 2, 1}, |
| 1008 | }, |
| 1009 | { |
| 1010 | name: "ok (must), params values empty, returns error, value is not changed", |
| 1011 | whenMust: true, |
| 1012 | whenURL: "/search?nope=1", |
| 1013 | expectValue: []uint64{99}, |
| 1014 | expectError: "code=400, message=required field value is empty, field=param", |
| 1015 | }, |
| 1016 | { |
| 1017 | name: "nok (must), previous errors fail fast without binding value", |
| 1018 | givenFailFast: true, |
| 1019 | whenMust: true, |
| 1020 | whenURL: "/search?param=1¶m=100", |
| 1021 | expectValue: []uint64{99}, |
| 1022 | expectError: "previous error", |
| 1023 | }, |
| 1024 | { |
| 1025 | name: "nok (must), conversion fails, value is not changed", |
| 1026 | whenMust: true, |
| 1027 | whenURL: "/search?param=nope¶m=100", |
nothing calls this directly
no test coverage detected
searching dependent graphs…