feat: migrate golangci-lint from v1 to v2 (#144)
Migrate golangci-lint from v1 to v2. ## Motivation and Context The golangci-lint has been upgraded to v2 since March 2025. The v2 of golangci-lint has simplified the linters management. ## How Has This Been Tested? Tested locally with golangci-lint@v2.1.6 ## Breaking Changes No. ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context <!-- Add any other context, implementation notes, or design decisions --> --------- Co-authored-by: haokunt <haokunt@opera.com> Co-authored-by: Avinash Sridhar <sridharavinash@users.noreply.github.com> Co-authored-by: Adam Jones <adamj+git@anthropic.com>
This commit is contained in:
parent
502b628ac8
commit
6ba612942e
3 changed files with 94 additions and 101 deletions
|
|
@ -23,17 +23,17 @@ type MockRegistryService struct {
|
|||
}
|
||||
|
||||
func (m *MockRegistryService) List(cursor string, limit int) ([]model.Server, string, error) {
|
||||
args := m.Mock.Called(cursor, limit)
|
||||
args := m.Called(cursor, limit)
|
||||
return args.Get(0).([]model.Server), args.String(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) GetByID(id string) (*model.ServerDetail, error) {
|
||||
args := m.Mock.Called(id)
|
||||
args := m.Called(id)
|
||||
return args.Get(0).(*model.ServerDetail), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockRegistryService) Publish(serverDetail *model.ServerDetail) error {
|
||||
args := m.Mock.Called(serverDetail)
|
||||
args := m.Called(serverDetail)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
|
|
@ -45,17 +45,17 @@ type MockAuthService struct {
|
|||
func (m *MockAuthService) StartAuthFlow(
|
||||
ctx context.Context, method model.AuthMethod, repoRef string,
|
||||
) (map[string]string, string, error) {
|
||||
args := m.Mock.Called(ctx, method, repoRef)
|
||||
args := m.Called(ctx, method, repoRef)
|
||||
return args.Get(0).(map[string]string), args.String(1), args.Error(2)
|
||||
}
|
||||
|
||||
func (m *MockAuthService) CheckAuthStatus(ctx context.Context, statusToken string) (string, error) {
|
||||
args := m.Mock.Called(ctx, statusToken)
|
||||
args := m.Called(ctx, statusToken)
|
||||
return args.String(0), args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockAuthService) ValidateAuth(ctx context.Context, authentication model.Authentication) (bool, error) {
|
||||
args := m.Mock.Called(ctx, authentication)
|
||||
args := m.Called(ctx, authentication)
|
||||
return args.Bool(0), args.Error(1)
|
||||
}
|
||||
|
||||
|
|
@ -416,8 +416,8 @@ func TestPublishHandler(t *testing.T) {
|
|||
}
|
||||
|
||||
// Assert that all expectations were met
|
||||
mockRegistry.Mock.AssertExpectations(t)
|
||||
mockAuthService.Mock.AssertExpectations(t)
|
||||
mockRegistry.AssertExpectations(t)
|
||||
mockAuthService.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -487,7 +487,7 @@ func TestPublishHandlerBearerTokenParsing(t *testing.T) {
|
|||
handler.ServeHTTP(rr, req)
|
||||
|
||||
assert.Equal(t, http.StatusCreated, rr.Code)
|
||||
mockAuthService.Mock.AssertExpectations(t)
|
||||
mockAuthService.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -552,7 +552,7 @@ func TestPublishHandlerAuthMethodSelection(t *testing.T) {
|
|||
handler.ServeHTTP(rr, req)
|
||||
|
||||
assert.Equal(t, http.StatusCreated, rr.Code)
|
||||
mockAuthService.Mock.AssertExpectations(t)
|
||||
mockAuthService.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -639,9 +639,9 @@ func TestPublishIntegration(t *testing.T) {
|
|||
// Verify the server was actually published by retrieving it
|
||||
publishedServer, err := registryService.GetByID(response["id"])
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, publishReq.ServerDetail.Name, publishedServer.Name)
|
||||
assert.Equal(t, publishReq.ServerDetail.Description, publishedServer.Description)
|
||||
assert.Equal(t, publishReq.ServerDetail.VersionDetail.Version, publishedServer.VersionDetail.Version)
|
||||
assert.Equal(t, publishReq.Name, publishedServer.Name)
|
||||
assert.Equal(t, publishReq.Description, publishedServer.Description)
|
||||
assert.Equal(t, publishReq.VersionDetail.Version, publishedServer.VersionDetail.Version)
|
||||
assert.Len(t, publishedServer.Packages, 1)
|
||||
assert.Len(t, publishedServer.Remotes, 1)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -60,12 +60,8 @@ func ServersHandler(registry service.RegistryService) http.HandlerFunc {
|
|||
return
|
||||
}
|
||||
|
||||
if parsedLimit > 100 {
|
||||
// Cap maximum limit to prevent excessive queries
|
||||
limit = 100
|
||||
} else {
|
||||
limit = parsedLimit
|
||||
}
|
||||
// Cap maximum limit to prevent excessive queries
|
||||
limit = min(parsedLimit, 100)
|
||||
}
|
||||
|
||||
// Use the GetAll method to get paginated results
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ func TestServersHandler(t *testing.T) {
|
|||
}
|
||||
|
||||
// Verify mock expectations
|
||||
mockRegistry.Mock.AssertExpectations(t)
|
||||
mockRegistry.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -321,7 +321,7 @@ func TestServersHandlerIntegration(t *testing.T) {
|
|||
assert.Empty(t, paginatedResp.Metadata.NextCursor)
|
||||
|
||||
// Verify mock expectations
|
||||
mockRegistry.Mock.AssertExpectations(t)
|
||||
mockRegistry.AssertExpectations(t)
|
||||
}
|
||||
|
||||
// TestServersDetailHandlerIntegration tests the servers detail handler with actual HTTP requests
|
||||
|
|
@ -387,5 +387,5 @@ func TestServersDetailHandlerIntegration(t *testing.T) {
|
|||
assert.Equal(t, *serverDetail, serverDetailResp)
|
||||
|
||||
// Verify mock expectations
|
||||
mockRegistry.Mock.AssertExpectations(t)
|
||||
mockRegistry.AssertExpectations(t)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue