fix: 修复若干问题,添加java lsp
This commit is contained in:
@@ -28,6 +28,14 @@ func (f *fakeCompletionService) Complete(_ context.Context, _ completion.Request
|
||||
return f.resp, nil
|
||||
}
|
||||
|
||||
type fakeLSPStatusProvider struct {
|
||||
status map[string]any
|
||||
}
|
||||
|
||||
func (f *fakeLSPStatusProvider) LspServiceStatus() map[string]any {
|
||||
return f.status
|
||||
}
|
||||
|
||||
// 验证 HTTP 补全接口的成功路径。
|
||||
func TestRegisterRoutesCompletionSuccess(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
@@ -174,3 +182,41 @@ func TestRegisterRoutesCompletionWebSocketSuccess(t *testing.T) {
|
||||
t.Fatalf("unexpected items: %+v", resp.Items)
|
||||
}
|
||||
}
|
||||
|
||||
// 验证 /health/lsp-status 会返回语言探测状态快照。
|
||||
func TestRegisterRoutesLspStatus(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
r := gin.New()
|
||||
RegisterRoutes(r, &fakeCompletionService{}, RouteOptions{
|
||||
LSPStatusProvider: &fakeLSPStatusProvider{
|
||||
status: map[string]any{
|
||||
"go": map[string]any{
|
||||
"online": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/health/lsp-status", nil)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("expected status 200, got %d", w.Code)
|
||||
}
|
||||
|
||||
var got map[string]any
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
|
||||
t.Fatalf("failed to decode response: %v", err)
|
||||
}
|
||||
if got["status"] != "ok" {
|
||||
t.Fatalf("expected status ok, got %#v", got["status"])
|
||||
}
|
||||
languages, ok := got["languages"].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("languages field type mismatch: %#v", got["languages"])
|
||||
}
|
||||
if _, ok := languages["go"]; !ok {
|
||||
t.Fatalf("expected go language status, got %#v", languages)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user