(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestWithMCPParse(t *testing.T) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | method string |
| 19 | path string |
| 20 | body string |
| 21 | expectInfo bool |
| 22 | expectedMethod string |
| 23 | expectedItem string |
| 24 | expectedOwner string |
| 25 | expectedRepo string |
| 26 | expectedArgs map[string]any |
| 27 | }{ |
| 28 | { |
| 29 | name: "health check path is skipped", |
| 30 | method: http.MethodPost, |
| 31 | path: "/_ping", |
| 32 | body: `{"jsonrpc":"2.0","method":"tools/list"}`, |
| 33 | expectInfo: false, |
| 34 | }, |
| 35 | { |
| 36 | name: "GET request is skipped", |
| 37 | method: http.MethodGet, |
| 38 | path: "/mcp", |
| 39 | body: `{"jsonrpc":"2.0","method":"tools/list"}`, |
| 40 | expectInfo: false, |
| 41 | }, |
| 42 | { |
| 43 | name: "empty body is skipped", |
| 44 | method: http.MethodPost, |
| 45 | path: "/mcp", |
| 46 | body: "", |
| 47 | expectInfo: false, |
| 48 | }, |
| 49 | { |
| 50 | name: "invalid JSON is skipped", |
| 51 | method: http.MethodPost, |
| 52 | path: "/mcp", |
| 53 | body: "not valid json", |
| 54 | expectInfo: false, |
| 55 | }, |
| 56 | { |
| 57 | name: "non-JSON-RPC 2.0 is skipped", |
| 58 | method: http.MethodPost, |
| 59 | path: "/mcp", |
| 60 | body: `{"jsonrpc":"1.0","method":"tools/list"}`, |
| 61 | expectInfo: false, |
| 62 | }, |
| 63 | { |
| 64 | name: "empty method is skipped", |
| 65 | method: http.MethodPost, |
| 66 | path: "/mcp", |
| 67 | body: `{"jsonrpc":"2.0","method":""}`, |
| 68 | expectInfo: false, |
| 69 | }, |
| 70 | { |
| 71 | name: "tools/list parses method only", |
| 72 | method: http.MethodPost, |
nothing calls this directly
no test coverage detected