MCPcopy Create free account
hub / github.com/goadesign/goa / TestHTTPRouteValidation

Function TestHTTPRouteValidation

expr/http_endpoint_test.go:13–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func 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.
22route 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
41func TestHTTPEndpointPrepare(t *testing.T) {
42 cases := map[string]struct {

Callers

nothing calls this directly

Calls 5

RunDSLFunction · 0.92
RunInvalidDSLFunction · 0.92
stripValidationLocationsFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected