-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix empty policy copy problem for arm/runtime.NewPipeline * add Copy() method for arm/policy.ClientOptions * rename Copy() to Clone() and fix ci failure
- Loading branch information
Showing
4 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package policy | ||
|
||
import ( | ||
"fmt" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestClientOptions_Copy(t *testing.T) { | ||
var option *ClientOptions | ||
require.Nil(t, option.Clone()) | ||
|
||
option = &ClientOptions{ClientOptions: policy.ClientOptions{ | ||
Cloud: cloud.AzurePublic, | ||
Logging: policy.LogOptions{ | ||
AllowedHeaders: []string{"test1", "test2"}, | ||
AllowedQueryParams: []string{"test1", "test2"}, | ||
}, | ||
Retry: policy.RetryOptions{StatusCodes: []int{1, 2}}, | ||
PerRetryPolicies: []policy.Policy{runtime.NewLogPolicy(nil)}, | ||
PerCallPolicies: []policy.Policy{runtime.NewLogPolicy(nil)}, | ||
}} | ||
copiedOption := option.Clone() | ||
require.Equal(t, option.APIVersion, copiedOption.APIVersion) | ||
require.NotEqual(t, fmt.Sprintf("%p", &option.APIVersion), fmt.Sprintf("%p", &copiedOption.APIVersion)) | ||
require.Equal(t, option.Cloud.Services, copiedOption.Cloud.Services) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.Cloud.Services), fmt.Sprintf("%p", copiedOption.Cloud.Services)) | ||
require.Equal(t, option.Logging.AllowedHeaders, copiedOption.Logging.AllowedHeaders) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.Logging.AllowedHeaders), fmt.Sprintf("%p", copiedOption.Logging.AllowedHeaders)) | ||
require.Equal(t, option.Logging.AllowedQueryParams, copiedOption.Logging.AllowedQueryParams) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.Logging.AllowedQueryParams), fmt.Sprintf("%p", copiedOption.Logging.AllowedQueryParams)) | ||
require.Equal(t, option.Retry.StatusCodes, copiedOption.Retry.StatusCodes) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.Retry.StatusCodes), fmt.Sprintf("%p", copiedOption.Retry.StatusCodes)) | ||
require.Equal(t, option.PerRetryPolicies, copiedOption.PerRetryPolicies) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.PerRetryPolicies), fmt.Sprintf("%p", copiedOption.PerRetryPolicies)) | ||
require.Equal(t, option.PerCallPolicies, copiedOption.PerCallPolicies) | ||
require.NotEqual(t, fmt.Sprintf("%p", option.PerCallPolicies), fmt.Sprintf("%p", copiedOption.PerCallPolicies)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters