testutil

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 13 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 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 StartProxy

func StartProxy(pathToPackage string) func()

StartProxy starts the test proxy with the path to store test recording file. It should be used in the module test preparation stage only once. It will return a delegate function to stop test proxy.

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