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

Function TestHTTPServiceValidate

expr/http_service_test.go:11–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestHTTPServiceValidate(t *testing.T) {
12 cases := []struct {
13 Name string
14 DSL func()
15 Error string
16 ContainsError string
17 }{
18 {"valid jsonrpc websocket", validJSONRPCWebSocketDSL, "", ""},
19 {"jsonrpc websocket with headers", jsonrpcWebSocketWithHeadersDSL, "", `JSON-RPC endpoint "method" using WebSocket cannot have header mappings`},
20 {"jsonrpc websocket with cookies", jsonrpcWebSocketWithCookiesDSL, "", `JSON-RPC endpoint "method" using WebSocket cannot have cookie mappings`},
21 {"jsonrpc websocket with params", jsonrpcWebSocketWithParamsDSL, "", `JSON-RPC endpoint "method" using WebSocket cannot have parameter mappings`},
22 {"jsonrpc websocket with all mappings", jsonrpcWebSocketWithAllMappingsDSL, "", `JSON-RPC endpoint "method" using WebSocket cannot have header mappings`},
23 }
24
25 for _, tc := range cases {
26 t.Run(tc.Name, func(t *testing.T) {
27 if tc.Error == "" && tc.ContainsError == "" {
28 expr.RunDSL(t, tc.DSL)
29 } else {
30 err := expr.RunInvalidDSL(t, tc.DSL)
31 if tc.Error != "" {
32 if err.Error() != tc.Error {
33 t.Errorf("got error %q, expected %q", err.Error(), tc.Error)
34 }
35 } else if tc.ContainsError != "" {
36 if !strings.Contains(err.Error(), tc.ContainsError) {
37 t.Errorf("error %q does not contain expected substring %q", err.Error(), tc.ContainsError)
38 }
39 }
40 }
41 })
42 }
43}
44
45// Test DSL functions
46

Callers

nothing calls this directly

Calls 4

RunDSLFunction · 0.92
RunInvalidDSLFunction · 0.92
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected