Documentation ¶
Index ¶
- Constants
- Variables
- func MakeBackendAddressPoolID(resourceGroupName, loadBalancerName string, backendAddressPoolName string) string
- func MakeLoadBalancerID(resourceGroupName, loadBalancerName string) string
- func NewProductPrice(instanceType string, price float64) client.Item
- func NewSpotProductPrice(instanceType string, price float64) client.Item
- type AtomicError
- type AtomicErrorOption
- type AtomicPtr
- type AtomicPtrSlice
- type AtomicPtrStack
- type AzureResourceGraphAPI
- type AzureResourceGraphBehavior
- type AzureResourceGraphResourcesInput
- type CommunityGalleryImageVersionsAPI
- type LoadBalancersAPI
- func (api *LoadBalancersAPI) Get(_ context.Context, resourceGroupName string, loadBalancerName string, ...) (armnetwork.LoadBalancersClientGetResponse, error)
- func (api *LoadBalancersAPI) NewListPager(_ string, _ *armnetwork.LoadBalancersClientListOptions) *runtime.Pager[armnetwork.LoadBalancersClientListResponse]
- func (api *LoadBalancersAPI) Reset()
- type LoadBalancersBehavior
- type MockHandler
- type MockSkuClientSingleton
- type MockedFunction
- type MockedLRO
- type NetworkInterfaceCreateOrUpdateInput
- type NetworkInterfaceDeleteInput
- type NetworkInterfacesAPI
- func (c *NetworkInterfacesAPI) BeginCreateOrUpdate(_ context.Context, resourceGroupName string, interfaceName string, ...) (*runtime.Poller[armnetwork.InterfacesClientCreateOrUpdateResponse], error)
- func (c *NetworkInterfacesAPI) BeginDelete(_ context.Context, resourceGroupName string, interfaceName string, ...) (*runtime.Poller[armnetwork.InterfacesClientDeleteResponse], error)
- func (c *NetworkInterfacesAPI) Get(_ context.Context, resourceGroupName string, interfaceName string, ...) (armnetwork.InterfacesClientGetResponse, error)
- func (c *NetworkInterfacesAPI) Reset()
- type NetworkInterfacesBehavior
- type PricingAPI
- type PricingBehavior
- type ResourceSKUsAPI
- type VirtualMachineCreateOrUpdateInput
- type VirtualMachineDeleteInput
- type VirtualMachineExtensionCreateOrUpdateInput
- type VirtualMachineExtensionsAPI
- type VirtualMachineExtensionsBehavior
- type VirtualMachineGetInput
- type VirtualMachineUpdateInput
- type VirtualMachinesAPI
- func (c *VirtualMachinesAPI) BeginCreateOrUpdate(_ context.Context, resourceGroupName string, vmName string, ...) (*runtime.Poller[armcompute.VirtualMachinesClientCreateOrUpdateResponse], error)
- func (c *VirtualMachinesAPI) BeginDelete(_ context.Context, resourceGroupName string, vmName string, ...) (*runtime.Poller[armcompute.VirtualMachinesClientDeleteResponse], error)
- func (c *VirtualMachinesAPI) BeginUpdate(_ context.Context, resourceGroupName string, vmName string, ...) (*runtime.Poller[armcompute.VirtualMachinesClientUpdateResponse], error)
- func (c *VirtualMachinesAPI) Get(_ context.Context, resourceGroupName string, vmName string, ...) (armcompute.VirtualMachinesClientGetResponse, error)
- func (c *VirtualMachinesAPI) Reset()
- type VirtualMachinesBehavior
Constants ¶
const Region = "eastus"
const RegionNonZonal = "westcentralus"
Variables ¶
var ResourceSkus = make(map[string][]compute.ResourceSku)
ResourceSkus is a map of location to resource skus
Functions ¶
func MakeLoadBalancerID ¶
Types ¶
type AtomicError ¶
type AtomicError struct {
// contains filtered or unexported fields
}
func (*AtomicError) Get ¶
func (e *AtomicError) Get() error
Get is equivalent to the error being called, so we increase number of calls in this function
func (*AtomicError) IsNil ¶
func (e *AtomicError) IsNil() bool
func (*AtomicError) Reset ¶
func (e *AtomicError) Reset()
func (*AtomicError) Set ¶
func (e *AtomicError) Set(err error, opts ...AtomicErrorOption)
type AtomicErrorOption ¶
type AtomicErrorOption func(atomicError *AtomicError)
func MaxCalls ¶
func MaxCalls(maxCalls int) AtomicErrorOption
type AtomicPtr ¶
type AtomicPtr[T any] struct { // contains filtered or unexported fields }
AtomicPtr is intended for use in mocks to easily expose variables for use in testing. It makes setting and retrieving the values race free by wrapping the pointer itself in a mutex. There is no Get() method, but instead a Clone() method deep copies the object being stored by serializing/de-serializing it from JSON. This pattern shouldn't be followed anywhere else but is an easy way to eliminate races in our tests.
type AtomicPtrSlice ¶
type AtomicPtrSlice[T any] struct { // contains filtered or unexported fields }
AtomicPtrSlice exposes a slice of a pointer type in a race-free manner.
func (*AtomicPtrSlice[T]) Append ¶
func (a *AtomicPtrSlice[T]) Append(input ...*T)
func (*AtomicPtrSlice[T]) Get ¶
func (a *AtomicPtrSlice[T]) Get(index int) *T
func (*AtomicPtrSlice[T]) Len ¶
func (a *AtomicPtrSlice[T]) Len() int
func (*AtomicPtrSlice[T]) Reset ¶
func (a *AtomicPtrSlice[T]) Reset()
type AtomicPtrStack ¶
type AtomicPtrStack[T any] struct { // contains filtered or unexported fields }
AtomicPtrStack exposes a slice of a pointer type in a race-free manner. The interface is just enough to replace the set.Set usage in our previous tests.
func (*AtomicPtrStack[T]) Add ¶
func (a *AtomicPtrStack[T]) Add(input *T)
func (*AtomicPtrStack[T]) Len ¶
func (a *AtomicPtrStack[T]) Len() int
func (*AtomicPtrStack[T]) Pop ¶
func (a *AtomicPtrStack[T]) Pop() *T
func (*AtomicPtrStack[T]) Reset ¶
func (a *AtomicPtrStack[T]) Reset()
type AzureResourceGraphAPI ¶
type AzureResourceGraphAPI struct {
AzureResourceGraphBehavior
}
func (*AzureResourceGraphAPI) Reset ¶
func (c *AzureResourceGraphAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
func (*AzureResourceGraphAPI) Resources ¶
func (c *AzureResourceGraphAPI) Resources(_ context.Context, query armresourcegraph.QueryRequest, options *armresourcegraph.ClientResourcesOptions) (armresourcegraph.ClientResourcesResponse, error)
type AzureResourceGraphBehavior ¶
type AzureResourceGraphBehavior struct { AzureResourceGraphResourcesBehavior MockedFunction[AzureResourceGraphResourcesInput, armresourcegraph.ClientResourcesResponse] VirtualMachinesAPI *VirtualMachinesAPI ResourceGroup string }
type AzureResourceGraphResourcesInput ¶
type AzureResourceGraphResourcesInput struct { Query armresourcegraph.QueryRequest Options *armresourcegraph.ClientResourcesOptions }
type CommunityGalleryImageVersionsAPI ¶
type CommunityGalleryImageVersionsAPI struct {
ImageVersions AtomicPtrSlice[armcompute.CommunityGalleryImageVersion]
}
func (*CommunityGalleryImageVersionsAPI) NewListPager ¶
func (c *CommunityGalleryImageVersionsAPI) NewListPager(_ string, _ string, _ string, _ *armcompute.CommunityGalleryImageVersionsClientListOptions) *runtime.Pager[armcompute.CommunityGalleryImageVersionsClientListResponse]
NewListPager returns a new pager to return the next page of CommunityGalleryImageVersionsClientListResponse
func (*CommunityGalleryImageVersionsAPI) Reset ¶
func (c *CommunityGalleryImageVersionsAPI) Reset()
type LoadBalancersAPI ¶
type LoadBalancersAPI struct {
LoadBalancersBehavior
}
func (*LoadBalancersAPI) Get ¶
func (api *LoadBalancersAPI) Get(_ context.Context, resourceGroupName string, loadBalancerName string, _ *armnetwork.LoadBalancersClientGetOptions) (armnetwork.LoadBalancersClientGetResponse, error)
func (*LoadBalancersAPI) NewListPager ¶
func (api *LoadBalancersAPI) NewListPager(_ string, _ *armnetwork.LoadBalancersClientListOptions) *runtime.Pager[armnetwork.LoadBalancersClientListResponse]
func (*LoadBalancersAPI) Reset ¶
func (api *LoadBalancersAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
type LoadBalancersBehavior ¶
type MockHandler ¶
type MockHandler[T any] struct { // contains filtered or unexported fields }
MockHandler returns a pre-defined result or error.
func (MockHandler[T]) Done ¶
func (h MockHandler[T]) Done() bool
Done returns true if the LRO has reached a terminal state. TrivialHandler is always done.
type MockSkuClientSingleton ¶
type MockSkuClientSingleton struct {
SKUClient *ResourceSKUsAPI
}
func (*MockSkuClientSingleton) GetInstance ¶
func (sc *MockSkuClientSingleton) GetInstance() skewer.ResourceClient
func (*MockSkuClientSingleton) Reset ¶
func (sc *MockSkuClientSingleton) Reset()
type MockedFunction ¶
type MockedFunction[I any, O any] struct { Output AtomicPtr[O] // Output to return on call to this function CalledWithInput AtomicPtrStack[I] // Stack used to keep track of passed input to this function Error AtomicError // Error to return a certain number of times defined by custom error options // contains filtered or unexported fields }
func (*MockedFunction[I, O]) Calls ¶
func (m *MockedFunction[I, O]) Calls() int
func (*MockedFunction[I, O]) FailedCalls ¶
func (m *MockedFunction[I, O]) FailedCalls() int
func (*MockedFunction[I, O]) Invoke ¶
func (m *MockedFunction[I, O]) Invoke(input *I, defaultTransformer func(*I) (O, error)) (O, error)
func (*MockedFunction[I, O]) Reset ¶
func (m *MockedFunction[I, O]) Reset()
Reset must be called between tests otherwise tests will pollute each other.
func (*MockedFunction[I, O]) SuccessfulCalls ¶
func (m *MockedFunction[I, O]) SuccessfulCalls() int
type MockedLRO ¶
type MockedLRO[I any, O any] struct { MockedFunction[I, O] BeginError AtomicError // Error to return a certain number of times defined by custom error options (for Begin) }
func (*MockedLRO[I, O]) FailedCalls ¶
func (*MockedLRO[I, O]) Reset ¶
func (m *MockedLRO[I, O]) Reset()
Reset must be called between tests otherwise tests will pollute each other.
func (*MockedLRO[I, O]) SuccessfulCalls ¶
type NetworkInterfaceCreateOrUpdateInput ¶
type NetworkInterfaceCreateOrUpdateInput struct { ResourceGroupName string InterfaceName string Interface armnetwork.Interface Options *armnetwork.InterfacesClientBeginCreateOrUpdateOptions }
type NetworkInterfaceDeleteInput ¶
type NetworkInterfaceDeleteInput struct {
ResourceGroupName, InterfaceName string
}
type NetworkInterfacesAPI ¶
type NetworkInterfacesAPI struct { // instance.NetworkInterfacesAPI NetworkInterfacesBehavior }
func (*NetworkInterfacesAPI) BeginCreateOrUpdate ¶
func (c *NetworkInterfacesAPI) BeginCreateOrUpdate(_ context.Context, resourceGroupName string, interfaceName string, iface armnetwork.Interface, options *armnetwork.InterfacesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armnetwork.InterfacesClientCreateOrUpdateResponse], error)
func (*NetworkInterfacesAPI) BeginDelete ¶
func (c *NetworkInterfacesAPI) BeginDelete(_ context.Context, resourceGroupName string, interfaceName string, _ *armnetwork.InterfacesClientBeginDeleteOptions) (*runtime.Poller[armnetwork.InterfacesClientDeleteResponse], error)
func (*NetworkInterfacesAPI) Get ¶
func (c *NetworkInterfacesAPI) Get(_ context.Context, resourceGroupName string, interfaceName string, _ *armnetwork.InterfacesClientGetOptions) (armnetwork.InterfacesClientGetResponse, error)
func (*NetworkInterfacesAPI) Reset ¶
func (c *NetworkInterfacesAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
type NetworkInterfacesBehavior ¶
type NetworkInterfacesBehavior struct { NetworkInterfacesCreateOrUpdateBehavior MockedLRO[NetworkInterfaceCreateOrUpdateInput, armnetwork.InterfacesClientCreateOrUpdateResponse] NetworkInterfacesDeleteBehavior MockedLRO[NetworkInterfaceDeleteInput, armnetwork.InterfacesClientDeleteResponse] NetworkInterfaces sync.Map }
type PricingAPI ¶
type PricingAPI struct { client.PricingAPI PricingBehavior }
func (*PricingAPI) GetProductsPricePages ¶
func (p *PricingAPI) GetProductsPricePages(_ context.Context, _ []*client.Filter, fn func(output *client.ProductsPricePage)) error
func (*PricingAPI) Reset ¶
func (p *PricingAPI) Reset()
type PricingBehavior ¶
type PricingBehavior struct { NextError AtomicError ProductsPricePage AtomicPtr[client.ProductsPricePage] }
type ResourceSKUsAPI ¶
type ResourceSKUsAPI struct {
Location string
}
func (*ResourceSKUsAPI) ListComplete ¶
func (s *ResourceSKUsAPI) ListComplete(_ context.Context, _, _ string) (compute.ResourceSkusResultIterator, error)
func (*ResourceSKUsAPI) Reset ¶
func (s *ResourceSKUsAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
type VirtualMachineCreateOrUpdateInput ¶
type VirtualMachineCreateOrUpdateInput struct { ResourceGroupName string VMName string VM armcompute.VirtualMachine Options *armcompute.VirtualMachinesClientBeginCreateOrUpdateOptions }
type VirtualMachineDeleteInput ¶
type VirtualMachineDeleteInput struct { ResourceGroupName string VMName string Options *armcompute.VirtualMachinesClientBeginDeleteOptions }
type VirtualMachineExtensionCreateOrUpdateInput ¶
type VirtualMachineExtensionCreateOrUpdateInput struct { ResourceGroupName string VirtualMachineName string VirtualMachineExtensionName string VirtualMachineExtension armcompute.VirtualMachineExtension Options *armcompute.VirtualMachineExtensionsClientBeginCreateOrUpdateOptions }
type VirtualMachineExtensionsAPI ¶
type VirtualMachineExtensionsAPI struct { // instance.VirtualMachineExtensionsAPI VirtualMachineExtensionsBehavior }
func (*VirtualMachineExtensionsAPI) BeginCreateOrUpdate ¶
func (c *VirtualMachineExtensionsAPI) BeginCreateOrUpdate(_ context.Context, resourceGroupName, vmName, extensionName string, extension armcompute.VirtualMachineExtension, options *armcompute.VirtualMachineExtensionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachineExtensionsClientCreateOrUpdateResponse], error)
func (*VirtualMachineExtensionsAPI) Reset ¶
func (c *VirtualMachineExtensionsAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
type VirtualMachineExtensionsBehavior ¶
type VirtualMachineExtensionsBehavior struct {
VirtualMachineExtensionsCreateOrUpdateBehavior MockedLRO[VirtualMachineExtensionCreateOrUpdateInput, armcompute.VirtualMachineExtensionsClientCreateOrUpdateResponse]
}
type VirtualMachineGetInput ¶
type VirtualMachineGetInput struct { ResourceGroupName string VMName string Options *armcompute.VirtualMachinesClientGetOptions }
type VirtualMachineUpdateInput ¶
type VirtualMachineUpdateInput struct { ResourceGroupName string VMName string Updates armcompute.VirtualMachineUpdate Options *armcompute.VirtualMachinesClientBeginUpdateOptions }
type VirtualMachinesAPI ¶
type VirtualMachinesAPI struct { // TODO: document the implications of embedding vs. not embedding the interface here // instance.VirtualMachinesAPI // - this is the interface we are mocking. VirtualMachinesBehavior }
func (*VirtualMachinesAPI) BeginCreateOrUpdate ¶
func (c *VirtualMachinesAPI) BeginCreateOrUpdate(_ context.Context, resourceGroupName string, vmName string, parameters armcompute.VirtualMachine, options *armcompute.VirtualMachinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientCreateOrUpdateResponse], error)
func (*VirtualMachinesAPI) BeginDelete ¶
func (c *VirtualMachinesAPI) BeginDelete(_ context.Context, resourceGroupName string, vmName string, options *armcompute.VirtualMachinesClientBeginDeleteOptions) (*runtime.Poller[armcompute.VirtualMachinesClientDeleteResponse], error)
func (*VirtualMachinesAPI) BeginUpdate ¶
func (c *VirtualMachinesAPI) BeginUpdate(_ context.Context, resourceGroupName string, vmName string, updates armcompute.VirtualMachineUpdate, options *armcompute.VirtualMachinesClientBeginUpdateOptions) (*runtime.Poller[armcompute.VirtualMachinesClientUpdateResponse], error)
func (*VirtualMachinesAPI) Get ¶
func (c *VirtualMachinesAPI) Get(_ context.Context, resourceGroupName string, vmName string, options *armcompute.VirtualMachinesClientGetOptions) (armcompute.VirtualMachinesClientGetResponse, error)
func (*VirtualMachinesAPI) Reset ¶
func (c *VirtualMachinesAPI) Reset()
Reset must be called between tests otherwise tests will pollute each other.
type VirtualMachinesBehavior ¶
type VirtualMachinesBehavior struct { VirtualMachineCreateOrUpdateBehavior MockedLRO[VirtualMachineCreateOrUpdateInput, armcompute.VirtualMachinesClientCreateOrUpdateResponse] VirtualMachineUpdateBehavior MockedLRO[VirtualMachineUpdateInput, armcompute.VirtualMachinesClientUpdateResponse] VirtualMachineDeleteBehavior MockedLRO[VirtualMachineDeleteInput, armcompute.VirtualMachinesClientDeleteResponse] VirtualMachineGetBehavior MockedFunction[VirtualMachineGetInput, armcompute.VirtualMachinesClientGetResponse] Instances sync.Map }