Make VirtualMachineImagesClient easier to mock

This commit is contained in:
Paul Meyer 2020-03-25 18:18:48 +00:00
parent a3b49cdc08
commit f0ec912ba6
2 changed files with 4 additions and 4 deletions

View File

@ -88,7 +88,7 @@ func (s azureClientSet) VirtualMachineImagesClient() VirtualMachineImagesClientA
c := compute.NewVirtualMachineImagesClient(s.subscriptionID) c := compute.NewVirtualMachineImagesClient(s.subscriptionID)
s.configureAutorestClient(&c.Client) s.configureAutorestClient(&c.Client)
c.PollingDelay = s.PollingDelay c.PollingDelay = s.PollingDelay
return virtualMachineImagesClientAPI{c} return VirtualMachineImagesClient{c}
} }
func (s azureClientSet) PollClient() autorest.Client { func (s azureClientSet) PollClient() autorest.Client {

View File

@ -19,9 +19,9 @@ type VirtualMachineImagesClientAPI interface {
GetLatest(ctx context.Context, publisher, offer, sku, location string) (*compute.VirtualMachineImageResource, error) GetLatest(ctx context.Context, publisher, offer, sku, location string) (*compute.VirtualMachineImageResource, error)
} }
var _ VirtualMachineImagesClientAPI = virtualMachineImagesClientAPI{} var _ VirtualMachineImagesClientAPI = VirtualMachineImagesClient{}
type virtualMachineImagesClientAPI struct { type VirtualMachineImagesClient struct {
computeapi.VirtualMachineImagesClientAPI computeapi.VirtualMachineImagesClientAPI
} }
@ -33,7 +33,7 @@ func ParsePlatformImageURN(urn string) (image *PlatformImage, err error) {
return &PlatformImage{parts[0], parts[1], parts[2], parts[3]}, nil return &PlatformImage{parts[0], parts[1], parts[2], parts[3]}, nil
} }
func (c virtualMachineImagesClientAPI) GetLatest(ctx context.Context, publisher, offer, sku, location string) (*compute.VirtualMachineImageResource, error) { func (c VirtualMachineImagesClient) GetLatest(ctx context.Context, publisher, offer, sku, location string) (*compute.VirtualMachineImageResource, error) {
result, err := c.List(ctx, location, publisher, offer, sku, "", to.Int32Ptr(1), "name desc") result, err := c.List(ctx, location, publisher, offer, sku, "", to.Int32Ptr(1), "name desc")
if err != nil { if err != nil {
return nil, err return nil, err