(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestHTTPErrorResponseValidation(t *testing.T) { |
| 11 | cases := []struct { |
| 12 | Name string |
| 13 | DSL func() |
| 14 | Error string |
| 15 | }{ |
| 16 | {"header string error", stringErrorResponseWithHeadersDSL, ""}, |
| 17 | {"header object result", objectErrorResponseWithHeadersDSL, ""}, |
| 18 | {"header array result", arrayErrorResponseWithHeadersDSL, ""}, |
| 19 | {"header map result", mapErrorResponseWithHeadersDSL, `HTTP response of service "MapErrorResponseWithHeaders" HTTP endpoint "Method": attribute "foo" used in HTTP headers must be a primitive type or an array of primitive types.`}, |
| 20 | {"implicit object in header", implicitObjectErrorResponseWithHeadersDSL, `HTTP response of service "ArrayObjectErrorResponseWithHeaders" HTTP endpoint "Method": attribute "foo" used in HTTP headers must be a primitive type or an array of primitive types.`}, |
| 21 | {"array of object in header", arrayObjectErrorResponseWithHeadersDSL, `HTTP response of service "ArrayObjectErrorResponseWithHeaders" HTTP endpoint "Method": Array error type is mapped to an HTTP header but is not an array of primitive types.`}, |
| 22 | {"map in header", mapErrorTypeResponseWithHeadersDSL, `HTTP response of service "MapErrorTypeResponseWithHeaders" HTTP endpoint "Method": error type must be a primitive type or an array of primitive types.`}, |
| 23 | {"missing header result attribute", missingHeaderErrorAttributeDSL, `HTTP response of service "MissingHeaderErrorAttribute" HTTP endpoint "Method": header "bar" has no equivalent attribute in error type, use notation 'attribute_name:header_name' to identify corresponding error type attribute.`}, |
| 24 | } |
| 25 | for _, c := range cases { |
| 26 | t.Run(c.Name, func(t *testing.T) { |
| 27 | if c.Error == "" { |
| 28 | expr.RunDSL(t, c.DSL) |
| 29 | } else { |
| 30 | err := expr.RunInvalidDSL(t, c.DSL) |
| 31 | if err.Error() != c.Error { |
| 32 | t.Errorf("\ngot error %q\nexpected %q", err.Error(), c.Error) |
| 33 | } |
| 34 | } |
| 35 | }) |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | var stringErrorResponseWithHeadersDSL = func() { |
| 40 | Service("StringErrorResponseWithHeaders", func() { |
nothing calls this directly
no test coverage detected