Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: SDK API client improvements #437

Merged
merged 1 commit into from
Jan 14, 2025
Merged

Conversation

maxtwardowski
Copy link
Member

This PR introduces the following changes:

  • Embed SDK's ClientInterface into ClientWithResponsesInterface
  • Use ClientWithResponsesInterface interface in ProviderConfig instead of concrete *sdk.ClientWithResponses type

This makes testing easier as we're no longer limited to response-less API calls, for example:

ctrl := gomock.NewController(t)
mockClient := mock_sdk.NewMockClientWithResponsesInterface(ctrl)
provider := &ProviderConfig{
    api: &sdk.ClientWithResponses{
        ClientInterface: mockClient,
    },
}

// Calling EXPECT() is now possible for both WithResponse and "response-less" methods
mockClient.EXPECT().UsersAPIListOrganizations(gomock.Any())
mockClient.EXPECT().UsersAPIListOrganizationsWithResponse(gomock.Any())

provider.api.UsersAPIListOrganizations(ctx)
provider.api.UsersAPIListOrganizationsWithResponse(ctx)

@maxtwardowski maxtwardowski requested a review from a team as a code owner January 14, 2025 14:12
@maxtwardowski maxtwardowski merged commit e014225 into master Jan 14, 2025
10 checks passed
@maxtwardowski maxtwardowski deleted the max/sdk-client-improvement branch January 14, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants