testutil

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

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

func NewRecordingPolicy(t *testing.T, o *recording.RecordingOptions) policy.Policy

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

func PollForTest[T any](ctx context.Context, poller *runtime.Poller[T]) (*T, error)

PollForTest will poll result according to the recording mode: Playback: customer poll loop until get result Others: use original poll until done

func StartRecording

func StartRecording(t *testing.T, pathToPackage string) func()

StartRecording starts the recording with the path to store recording file. It will return a delegate function to stop recording.

func StopRecording

func StopRecording(t *testing.T)

StopRecording stops the recording.

Types

type FakeCredential

type FakeCredential struct {
}

FakeCredential is an empty credential for testing.

func (*FakeCredential) GetToken

GetToken provide a fake access token.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL