mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-07 15:10:01 +08:00
chore: add more unit tests for mcp (#4928)
This commit is contained in:
@@ -175,6 +175,20 @@ func TestHandleRequest_badRequest(t *testing.T) {
|
||||
mock.server.handleRequest(w, r)
|
||||
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||
})
|
||||
|
||||
t.Run("bad id", func(t *testing.T) {
|
||||
mock := newMockMcpServer(t)
|
||||
defer mock.shutdown()
|
||||
|
||||
addTestClient(mock.server, "test-session", true)
|
||||
|
||||
body := `{"jsonrpc": "2.0", "id": {}, "method": "tools.call", "params": {}}`
|
||||
r := httptest.NewRequest(http.MethodPost, "/?session_id=test-session", bytes.NewReader([]byte(body)))
|
||||
w := httptest.NewRecorder()
|
||||
mock.server.handleRequest(w, r)
|
||||
assert.Equal(t, http.StatusBadRequest, w.Code)
|
||||
assert.Contains(t, w.Body.String(), "Invalid request.ID")
|
||||
})
|
||||
}
|
||||
|
||||
func TestRegisterTool(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user