Skip to content

Commit c4b7a94

Browse files
jongioCopilot
andcommitted
refactor: replace to.Ptr() with new() per Go 1.26 convention
Replace 20 to.Ptr() calls with new() in bicep_provider_test.go and remove unused azure-sdk-for-go/sdk/azcore/to import per AGENTS.md Go 1.26 guidelines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6ae0bcc commit c4b7a94

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

cli/azd/pkg/infra/provisioning/bicep/bicep_provider_test.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
2323
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
24-
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
2524
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement"
2625
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration"
2726
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault"
@@ -531,7 +530,7 @@ func TestBicepDestroyClassifyAndDelete(t *testing.T) {
531530
{
532531
Name: new("no-delete"),
533532
Properties: &armlocks.ManagementLockProperties{
534-
Level: to.Ptr(armlocks.LockLevelCanNotDelete),
533+
Level: new(armlocks.LockLevelCanNotDelete),
535534
},
536535
},
537536
},
@@ -865,7 +864,7 @@ var testEnvDeployment armresources.DeploymentExtended = armresources.DeploymentE
865864
ID: new("/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP"),
866865
},
867866
},
868-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
867+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
869868
Timestamp: new(time.Now()),
870869
},
871870
}
@@ -939,7 +938,7 @@ func prepareDestroyMocks(mockContext *mocks.MockContext) {
939938
ID: new(azure.ResourceGroupRID("SUBSCRIPTION_ID", "RESOURCE_GROUP")),
940939
Location: new("eastus2"),
941940
Name: new("RESOURCE_GROUP"),
942-
Type: to.Ptr(string(azapi.AzureResourceTypeResourceGroup)),
941+
Type: new(string(azapi.AzureResourceTypeResourceGroup)),
943942
Tags: map[string]*string{
944943
"azd-env-name": new("test-env"),
945944
},
@@ -1088,7 +1087,7 @@ func prepareDestroyMocks(mockContext *mocks.MockContext) {
10881087
},
10891088
Type: new("Microsoft.Resources/deployments"),
10901089
Properties: &armresources.DeploymentPropertiesExtended{
1091-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
1090+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
10921091
Timestamp: new(time.Now()),
10931092
},
10941093
},
@@ -1246,7 +1245,7 @@ func prepareLogAnalyticsDestroyMocks(mockContext *mocks.MockContext) {
12461245
ID: new(azure.ResourceGroupRID("SUBSCRIPTION_ID", "RESOURCE_GROUP")),
12471246
Location: new("eastus2"),
12481247
Name: new("RESOURCE_GROUP"),
1249-
Type: to.Ptr(string(azapi.AzureResourceTypeResourceGroup)),
1248+
Type: new(string(azapi.AzureResourceTypeResourceGroup)),
12501249
Tags: map[string]*string{
12511250
"azd-env-name": new("test-env"),
12521251
},
@@ -1306,7 +1305,7 @@ func prepareLogAnalyticsDestroyMocks(mockContext *mocks.MockContext) {
13061305
{
13071306
OperationID: new("op-rg-create"),
13081307
Properties: &armresources.DeploymentOperationProperties{
1309-
ProvisioningOperation: to.Ptr(armresources.ProvisioningOperationCreate),
1308+
ProvisioningOperation: new(armresources.ProvisioningOperationCreate),
13101309
TargetResource: &armresources.TargetResource{
13111310
ResourceType: new("Microsoft.Resources/resourceGroups"),
13121311
ResourceName: new("RESOURCE_GROUP"),
@@ -1339,7 +1338,7 @@ func prepareLogAnalyticsDestroyMocks(mockContext *mocks.MockContext) {
13391338
},
13401339
Type: new("Microsoft.Resources/deployments"),
13411340
Properties: &armresources.DeploymentPropertiesExtended{
1342-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
1341+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
13431342
Timestamp: new(time.Now()),
13441343
},
13451344
},
@@ -1431,7 +1430,7 @@ func prepareClassifyDestroyMocks(
14311430
"WEBSITE_URL": map[string]any{"value": "http://myapp.azurewebsites.net", "type": "string"},
14321431
},
14331432
OutputResources: outputResources,
1434-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
1433+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
14351434
Timestamp: new(time.Now()),
14361435
},
14371436
}
@@ -1595,7 +1594,7 @@ func prepareClassifyDestroyMocks(
15951594
Tags: map[string]*string{"azd-env-name": new("test-env")},
15961595
Type: new("Microsoft.Resources/deployments"),
15971596
Properties: &armresources.DeploymentPropertiesExtended{
1598-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
1597+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
15991598
Timestamp: new(time.Now()),
16001599
},
16011600
},
@@ -2288,7 +2287,7 @@ func TestPreviewWithNilResourceState(t *testing.T) {
22882287
Changes: []*armresources.WhatIfChange{
22892288
// Create scenario: Before is nil, After has value
22902289
{
2291-
ChangeType: to.Ptr(armresources.ChangeTypeCreate),
2290+
ChangeType: new(armresources.ChangeTypeCreate),
22922291
ResourceID: new("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/app1"),
22932292
Before: nil,
22942293
After: map[string]any{
@@ -2298,7 +2297,7 @@ func TestPreviewWithNilResourceState(t *testing.T) {
22982297
},
22992298
// Delete scenario: After is nil, Before has value
23002299
{
2301-
ChangeType: to.Ptr(armresources.ChangeTypeDelete),
2300+
ChangeType: new(armresources.ChangeTypeDelete),
23022301
ResourceID: new("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/app2"),
23032302
Before: map[string]any{
23042303
"type": "Microsoft.Web/sites",
@@ -2308,7 +2307,7 @@ func TestPreviewWithNilResourceState(t *testing.T) {
23082307
},
23092308
// Modify scenario: Both Before and After have values
23102309
{
2311-
ChangeType: to.Ptr(armresources.ChangeTypeModify),
2310+
ChangeType: new(armresources.ChangeTypeModify),
23122311
ResourceID: new("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Web/sites/app3"),
23132312
Before: map[string]any{
23142313
"type": "Microsoft.Web/sites",
@@ -2321,7 +2320,7 @@ func TestPreviewWithNilResourceState(t *testing.T) {
23212320
},
23222321
// Edge case: Both Before and After are nil (should be skipped)
23232322
{
2324-
ChangeType: to.Ptr(armresources.ChangeTypeUnsupported),
2323+
ChangeType: new(armresources.ChangeTypeUnsupported),
23252324
ResourceID: new("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Unknown/unknown"),
23262325
Before: nil,
23272326
After: nil,
@@ -3113,7 +3112,7 @@ func TestBicepDestroyViaDeploymentStacks(t *testing.T) {
31133112
"WEBSITE_URL": map[string]any{"value": "http://myapp.azurewebsites.net", "type": "string"},
31143113
},
31153114
OutputResources: []*armresources.ResourceReference{{ID: &rgID}},
3116-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3115+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
31173116
Timestamp: new(time.Now()),
31183117
},
31193118
}
@@ -3265,7 +3264,7 @@ func TestBicepDestroyDeleteRGListPartialFailure(t *testing.T) {
32653264
"WEBSITE_URL": map[string]any{"value": "http://myapp.azurewebsites.net", "type": "string"},
32663265
},
32673266
OutputResources: outputResources,
3268-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3267+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
32693268
Timestamp: new(time.Now()),
32703269
},
32713270
}
@@ -3408,7 +3407,7 @@ func TestBicepDestroyDeleteRGListPartialFailure(t *testing.T) {
34083407
Tags: map[string]*string{"azd-env-name": new("test-env")},
34093408
Type: new("Microsoft.Resources/deployments"),
34103409
Properties: &armresources.DeploymentPropertiesExtended{
3411-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3410+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
34123411
Timestamp: new(time.Now()),
34133412
},
34143413
},
@@ -3483,7 +3482,7 @@ func TestBicepDestroyPartialDeleteAttemptsPurge(t *testing.T) {
34833482
"WEBSITE_URL": map[string]any{"value": "http://myapp.azurewebsites.net", "type": "string"},
34843483
},
34853484
OutputResources: outputResources,
3486-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3485+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
34873486
Timestamp: new(time.Now()),
34883487
},
34893488
}
@@ -3646,7 +3645,7 @@ func TestBicepDestroyPartialDeleteAttemptsPurge(t *testing.T) {
36463645
Tags: map[string]*string{"azd-env-name": new("test-env")},
36473646
Type: new("Microsoft.Resources/deployments"),
36483647
Properties: &armresources.DeploymentPropertiesExtended{
3649-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3648+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
36503649
Timestamp: new(time.Now()),
36513650
},
36523651
},
@@ -3739,7 +3738,7 @@ func TestBicepDestroyCredentialResolutionFailure(t *testing.T) {
37393738
"WEBSITE_URL": map[string]any{"value": "http://myapp.azurewebsites.net", "type": "string"},
37403739
},
37413740
OutputResources: []*armresources.ResourceReference{{ID: &rgID}},
3742-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3741+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
37433742
Timestamp: new(time.Now()),
37443743
},
37453744
}
@@ -3832,7 +3831,7 @@ func TestBicepDestroyCredentialResolutionFailure(t *testing.T) {
38323831
Tags: map[string]*string{"azd-env-name": new("test-env")},
38333832
Type: new("Microsoft.Resources/deployments"),
38343833
Properties: &armresources.DeploymentPropertiesExtended{
3835-
ProvisioningState: to.Ptr(armresources.ProvisioningStateSucceeded),
3834+
ProvisioningState: new(armresources.ProvisioningStateSucceeded),
38363835
Timestamp: new(time.Now()),
38373836
},
38383837
},

0 commit comments

Comments
 (0)