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 GenerateAlphaNumericID(t *testing.T, prefix string, length int) string
- func GetCredAndClientOptions(t *testing.T) (azcore.TokenCredential, *arm.ClientOptions)
- func GetEnv(key, fallback string) string
- 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 ¶ added in v0.2.0
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 GenerateAlphaNumericID ¶ added in v1.1.0
GenerateAlphaNumericID will generate a random alpha numeric ID. When handling live request, the random seed is generated. Otherwise, the random seed is stable and will be stored in recording file. The length parameter is the random part length, not include the prefix part. Deprecated: use github.com/Azure/azure-sdk-for-go/sdk/internal/recording.GenerateAlphaNumericID instead.
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 GetEnv ¶
GetEnv will return the os env variable and fallback to the given string if env variable not exist. Deprecated: use github.com/Azure/azure-sdk-for-go/sdk/internal/recording.GetEnvVariable instead.
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 ¶ added in v0.3.0
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 ¶ added in v1.0.0
type FakeCredential struct { }
FakeCredential is an empty credential for testing.
func (*FakeCredential) GetToken ¶ added in v1.0.0
func (c *FakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error)
GetToken provide a fake access token.