Documentation ¶
Index ¶
- func CreateDeployment(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, ...) (*armresources.DeploymentExtended, error)
- func CreateResourceGroup(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, ...) (*armresources.ResourceGroup, ...)
- func DeleteResourceGroup(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, ...) (*runtime.Poller[armresources.ResourceGroupsClientDeleteResponse], error)
- func GetCredAndClientOptions(t *testing.T) (azcore.TokenCredential, *arm.ClientOptions)
- func NewRecordingPolicy(t *testing.T, o *recording.RecordingOptions) policy.Policy
- func PollForTest[T any](ctx context.Context, poller *runtime.Poller[T]) (*T, error)
- func StartRecording(t *testing.T, pathToPackage string) func()
- func StopRecording(t *testing.T)
- type FakeCredential
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDeployment ¶
func CreateDeployment(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, options *arm.ClientOptions, resourceGroupName, deploymentName string, deployment *armresources.Deployment) (*armresources.DeploymentExtended, error)
CreateDeployment will create a resource using arm template. It will return the deployment result entity.
func CreateResourceGroup ¶
func CreateResourceGroup(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, options *arm.ClientOptions, location string) (*armresources.ResourceGroup, func() (*runtime.Poller[armresources.ResourceGroupsClientDeleteResponse], error), error)
CreateResourceGroup will create a resource group with a random generated name: "go-sdk-test-xxx". It will return the created resource group entity, a delegate function to delete the created resource group which can be used for clean up and any error during the creation.
func DeleteResourceGroup ¶
func DeleteResourceGroup(ctx context.Context, subscriptionId string, cred azcore.TokenCredential, options *arm.ClientOptions, resourceGroupName string) (*runtime.Poller[armresources.ResourceGroupsClientDeleteResponse], error)
DeleteResourceGroup will delete the resource group with the given name. It will do the deletion asynchronously and return the poller which can be used to wait for the result.
func GetCredAndClientOptions ¶
func GetCredAndClientOptions(t *testing.T) (azcore.TokenCredential, *arm.ClientOptions)
GetCredAndClientOptions will create a credential and a client options for test application. They can be used in any Azure resource management client. The client options will initialize the transport for recording client add recording policy to the pipeline. In the record mode, the credential will be a DefaultAzureCredential which combines several common credentials. In the playback mode, the credential will be a fake credential which will bypass truly authorization.
func NewRecordingPolicy ¶
NewRecordingPolicy will create a recording policy which can be used in pipeline. The policy will change the destination of the request to the proxy server and add required header for the recording test.
func PollForTest ¶
PollForTest will poll result according to the recording mode: Playback: customer poll loop until get result Others: use original poll until done
func StartRecording ¶
StartRecording starts the recording with the path to store recording file. It will return a delegate function to stop recording.
Types ¶
type FakeCredential ¶
type FakeCredential struct { }
FakeCredential is an empty credential for testing.
func (*FakeCredential) GetToken ¶
func (c *FakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error)
GetToken provide a fake access token.