(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 |
nothing calls this directly
no test coverage detected