Rename api/v1 -> api/v0 to match API paths (#320)
This PR renames the API paths from v1 to v0 to align with the actual API versioning scheme.
This commit is contained in:
parent
099a2d702e
commit
c0a94cca8c
1 changed files with 176 additions and 177 deletions
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/danielgtaylor/huma/v2/adapters/humago"
|
||||
"github.com/google/uuid"
|
||||
v0 "github.com/modelcontextprotocol/registry/internal/api/handlers/v0"
|
||||
apiv1 "github.com/modelcontextprotocol/registry/pkg/api/v1"
|
||||
apiv0 "github.com/modelcontextprotocol/registry/pkg/api/v0"
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
|
@ -24,14 +24,14 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
queryParams string
|
||||
setupMocks func(*MockRegistryService)
|
||||
expectedStatus int
|
||||
expectedServers []apiv1.ServerRecord
|
||||
expectedServers []apiv0.ServerRecord
|
||||
expectedMeta *v0.Metadata
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "successful list with default parameters",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-1",
|
||||
|
|
@ -45,7 +45,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
},
|
||||
},
|
||||
|
|
@ -62,7 +62,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
},
|
||||
},
|
||||
|
|
@ -70,7 +70,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
registry.Mock.On("List", "", 30).Return(servers, "", nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
expectedServers: []apiv1.ServerRecord{
|
||||
expectedServers: []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-1",
|
||||
|
|
@ -84,7 +84,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440001",
|
||||
},
|
||||
},
|
||||
|
|
@ -101,7 +101,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440002",
|
||||
},
|
||||
},
|
||||
|
|
@ -111,7 +111,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
name: "successful list with cursor and limit",
|
||||
queryParams: "?cursor=550e8400-e29b-41d4-a716-446655440000&limit=10",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-3",
|
||||
|
|
@ -125,7 +125,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.5.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440003",
|
||||
},
|
||||
},
|
||||
|
|
@ -134,7 +134,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
registry.Mock.On("List", mock.AnythingOfType("string"), 10).Return(servers, nextCursor, nil)
|
||||
},
|
||||
expectedStatus: http.StatusOK,
|
||||
expectedServers: []apiv1.ServerRecord{
|
||||
expectedServers: []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-3",
|
||||
|
|
@ -148,7 +148,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
Version: "1.5.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: "550e8400-e29b-41d4-a716-446655440003",
|
||||
},
|
||||
},
|
||||
|
|
@ -196,7 +196,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
{
|
||||
name: "registry service error",
|
||||
setupMocks: func(registry *MockRegistryService) {
|
||||
registry.Mock.On("List", "", 30).Return([]apiv1.ServerRecord{}, "", errors.New("database connection error"))
|
||||
registry.Mock.On("List", "", 30).Return([]apiv0.ServerRecord{}, "", errors.New("database connection error"))
|
||||
},
|
||||
expectedStatus: http.StatusInternalServerError,
|
||||
expectedError: "Failed to get registry list",
|
||||
|
|
@ -233,7 +233,7 @@ func TestServersListEndpoint(t *testing.T) {
|
|||
|
||||
// Parse response body
|
||||
var resp struct {
|
||||
Servers []apiv1.ServerRecord `json:"servers"`
|
||||
Servers []apiv0.ServerRecord `json:"servers"`
|
||||
Metadata *v0.Metadata `json:"metadata,omitempty"`
|
||||
}
|
||||
err := json.NewDecoder(w.Body).Decode(&resp)
|
||||
|
|
@ -268,14 +268,14 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
serverID string
|
||||
setupMocks func(*MockRegistryService, string)
|
||||
expectedStatus int
|
||||
expectedServer *apiv1.ServerRecord
|
||||
expectedServer *apiv0.ServerRecord
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "successful get server detail",
|
||||
serverID: uuid.New().String(),
|
||||
setupMocks: func(registry *MockRegistryService, serverID string) {
|
||||
serverDetail := &apiv1.ServerRecord{
|
||||
serverDetail := &apiv0.ServerRecord{
|
||||
Server: model.ServerJSON{
|
||||
Name: "test-server-detail",
|
||||
Description: "Test server detail",
|
||||
|
|
@ -288,7 +288,7 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
Version: "2.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: serverID,
|
||||
},
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ func TestServersDetailEndpoint(t *testing.T) {
|
|||
assert.Equal(t, "application/json", w.Header().Get("Content-Type"))
|
||||
|
||||
// Parse response body
|
||||
var serverDetailResp apiv1.ServerRecord
|
||||
var serverDetailResp apiv0.ServerRecord
|
||||
err := json.NewDecoder(w.Body).Decode(&serverDetailResp)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
@ -376,7 +376,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
|
||||
// Test data
|
||||
serverID := uuid.New().String()
|
||||
servers := []apiv1.ServerRecord{
|
||||
servers := []apiv0.ServerRecord{
|
||||
{
|
||||
Server: model.ServerJSON{
|
||||
Name: "integration-test-server",
|
||||
|
|
@ -390,13 +390,13 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
Version: "1.0.0",
|
||||
},
|
||||
},
|
||||
XIOModelContextProtocolRegistry: apiv1.RegistryExtensions{
|
||||
XIOModelContextProtocolRegistry: apiv0.RegistryExtensions{
|
||||
ID: serverID,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
serverDetail := &apiv1.ServerRecord{
|
||||
serverDetail := &apiv0.ServerRecord{
|
||||
Server: servers[0].Server,
|
||||
XIOModelContextProtocolRegistry: servers[0].XIOModelContextProtocolRegistry,
|
||||
}
|
||||
|
|
@ -439,7 +439,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
|
||||
// Parse response body
|
||||
var listResp struct {
|
||||
Servers []apiv1.ServerRecord `json:"servers"`
|
||||
Servers []apiv0.ServerRecord `json:"servers"`
|
||||
}
|
||||
err = json.NewDecoder(resp.Body).Decode(&listResp)
|
||||
assert.NoError(t, err)
|
||||
|
|
@ -470,7 +470,7 @@ func TestServersEndpointsIntegration(t *testing.T) {
|
|||
assert.Equal(t, "application/json", resp.Header.Get("Content-Type"))
|
||||
|
||||
// Parse response body
|
||||
var serverDetailResp apiv1.ServerRecord
|
||||
var serverDetailResp apiv0.ServerRecord
|
||||
err = json.NewDecoder(resp.Body).Decode(&serverDetailResp)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue