(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestHTTPRouteValidation(t *testing.T) { |
| 14 | cases := []struct { |
| 15 | Name string |
| 16 | DSL func() |
| 17 | Error string |
| 18 | }{ |
| 19 | {"valid", testdata.ValidRouteDSL, ""}, |
| 20 | {"duplicate-wc-route", testdata.DuplicateWCRouteDSL, `route POST "/{id}" of service "DuplicateWCRoute" HTTP endpoint "Method": Wildcard "id" appears multiple times in full path "/{id}/{id}"`}, |
| 21 | {"disallow-response-body", testdata.DisallowResponseBodyHeadDSL, `route HEAD "/" of service "DisallowResponseBody" HTTP endpoint "Method": HTTP status 200: Response body defined for HEAD method which does not allow response body. |
| 22 | route HEAD "/" of service "DisallowResponseBody" HTTP endpoint "Method": HTTP status 404: Response body defined for HEAD method which does not allow response body.`, |
| 23 | }, |
| 24 | {"invalid", testdata.InvalidRouteDSL, "routes at the service level are only allowed for JSON-RPC services. Use method-level routes instead. in service \"InvalidRoute\""}, |
| 25 | } |
| 26 | for _, c := range cases { |
| 27 | t.Run(c.Name, func(t *testing.T) { |
| 28 | if c.Error == "" { |
| 29 | expr.RunDSL(t, c.DSL) |
| 30 | } else { |
| 31 | err := expr.RunInvalidDSL(t, c.DSL) |
| 32 | got := stripValidationLocations(err.Error()) |
| 33 | if !strings.HasSuffix(got, c.Error) { |
| 34 | t.Errorf("got error %q\nexpected %q", got, c.Error) |
| 35 | } |
| 36 | } |
| 37 | }) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestHTTPEndpointPrepare(t *testing.T) { |
| 42 | cases := map[string]struct { |
nothing calls this directly
no test coverage detected