Changes on the server.json format and the API (#562)

This commit is contained in:
Radoslav Dimitrov 2025-09-29 23:30:35 +03:00 • committed by GitHub
commit b21c6f564d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,7 @@ import (
"context"
"net/http"
"net/http/httptest"
"net/url"
"testing"
"github.com/danielgtaylor/huma/v2"
@ -22,7 +23,7 @@ import (
func TestPrometheusHandler(t *testing.T) {
registryService := service.NewRegistryService(database.NewTestDB(t), config.NewConfig())
server, err := registryService.Publish(apiv0.ServerJSON{
server, err := registryService.CreateServer(context.Background(), &apiv0.ServerJSON{
Name: "io.github.example/test-server",
Description: "Test server detail",
Repository: model.Repository{
@ -50,8 +51,8 @@ func TestPrometheusHandler(t *testing.T) {
// Add /metrics for Prometheus metrics using promhttp
mux.Handle("/metrics", metrics.PrometheusHandler())
// Create request
url := "/v0/servers/" + server.Meta.Official.ServerID
// Create request - using new name-based API
url := "/v0/servers/" + url.PathEscape(server.Server.Name)
req := httptest.NewRequest(http.MethodGet, url, nil)
w := httptest.NewRecorder()
@ -76,5 +77,5 @@ func TestPrometheusHandler(t *testing.T) {
// Check if the response body contains expected metrics
assert.Contains(t, body, "mcp_registry_http_request_duration_bucket")
assert.Contains(t, body, "mcp_registry_http_requests_total")
assert.Contains(t, body, "path=\"/v0/servers/{server_id}\"")
assert.Contains(t, body, "path=\"/v0/servers/{serverName}\"")
}