Skip to content

expose FabricClient interface #1028

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

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

jordanstephens
Copy link
Member

@jordanstephens jordanstephens commented Feb 24, 2025

Description

This PR extracts a mockable FabricClient interface to support unit testing in the V1 Defang Pulumi Provider: DefangLabs/pulumi-defang#54

In order to do this, I needed to avoid accessing data attributes directly, so I implemented GetTenantName and GetController.

Linked Issues

DefangLabs/pulumi-defang#54

Checklist

  • I have performed a self-review of my code
  • I have added appropriate tests
  • I have updated the Defang CLI docs and/or README to reflect my changes, if necessary

Copy link
Member

@lionello lionello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gRPC interface is perfect for mocking, so I'd mock that instead.

@jordanstephens
Copy link
Member Author

The gRPC interface is perfect for mocking, so I'd mock that instead.

GrpcClient is a type which implements the FabricClient interface. My understanding is that if you want to mock a type in go, you define an interface which that type implements, then you create a new type which also implements interface. That's what I've done here.

@jordanstephens jordanstephens merged commit 93e57b3 into main Feb 26, 2025
12 checks passed
@jordanstephens jordanstephens deleted the jordan/expose-fabric-client-interface branch February 26, 2025 18:47
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