diff --git a/controllers/eventhub_controller.go b/controllers/eventhub_controller.go index d9a46e034c7..97b3e529691 100644 --- a/controllers/eventhub_controller.go +++ b/controllers/eventhub_controller.go @@ -18,6 +18,7 @@ package controllers import ( "context" "fmt" + "net/http" "time" "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" @@ -136,12 +137,12 @@ func (r *EventhubReconciler) reapply(instance *azurev1.Eventhub) error { secretName := instance.Spec.SecretName result, _ := r.EventHubManager.GetHub(ctx, resourcegroup, eventhubNamespace, eventhubName) - if result.Response.StatusCode == 404 { + if result.Response.StatusCode == http.StatusNotFound { r.reconcileExternal(instance) r.Recorder.Event(instance, "Normal", "Updated", "Resource does not exist in azure, reapplied it") } - if result.Response.StatusCode == 200 { + if result.Response.StatusCode == http.StatusOK { //get secret for eventhub err = r.getEventhubSecrets(secretName, instance) if err != nil { diff --git a/controllers/keyvault_controller_test.go b/controllers/keyvault_controller_test.go index e168b0393fa..9630590d936 100644 --- a/controllers/keyvault_controller_test.go +++ b/controllers/keyvault_controller_test.go @@ -17,6 +17,7 @@ import ( "context" "fmt" "log" + "net/http" "strings" "time" @@ -72,7 +73,7 @@ var _ = Describe("KeyVault Controller", func() { // verify key vault exists in Azure Eventually(func() bool { result, _ := tc.keyVaultManager.GetVault(context.Background(), tc.resourceGroupName, keyVaultInstance.Name) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, tc.timeout, ).Should(BeTrue()) @@ -93,7 +94,7 @@ var _ = Describe("KeyVault Controller", func() { // confirm key vault is gone from Azure Eventually(func() bool { result, _ := tc.keyVaultManager.GetVault(context.Background(), tc.resourceGroupName, keyVaultInstance.Name) - return result.Response.StatusCode == 404 + return result.Response.StatusCode == http.StatusNotFound }, tc.timeout, poll, ).Should(BeTrue()) }) diff --git a/pkg/helpers/helpers.go b/pkg/helpers/helpers.go index e033f019db0..99ddb20ffd6 100644 --- a/pkg/helpers/helpers.go +++ b/pkg/helpers/helpers.go @@ -4,6 +4,7 @@ import ( "crypto/md5" "fmt" "io" + "net/http" "regexp" "strings" @@ -36,7 +37,7 @@ func IgnoreKubernetesResourceNotFound(err error) error { } func IgnoreAzureResourceNotFound(err error) error { - if err.(autorest.DetailedError).StatusCode.(int) == 404 { + if err.(autorest.DetailedError).StatusCode.(int) == http.StatusNotFound { return nil } return err diff --git a/pkg/resourcemanager/eventhubs/consumergroup_test.go b/pkg/resourcemanager/eventhubs/consumergroup_test.go index 98afca36c93..21cecd078b2 100644 --- a/pkg/resourcemanager/eventhubs/consumergroup_test.go +++ b/pkg/resourcemanager/eventhubs/consumergroup_test.go @@ -18,6 +18,7 @@ package eventhubs import ( "context" + "net/http" "time" helpers "github.com/Azure/azure-service-operator/pkg/helpers" @@ -71,7 +72,7 @@ var _ = Describe("ConsumerGroup", func() { Eventually(func() bool { result, _ := consumerGroupManager.GetConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -80,7 +81,7 @@ var _ = Describe("ConsumerGroup", func() { Eventually(func() bool { result, _ := consumerGroupManager.GetConsumerGroup(context.Background(), rgName, eventhubNamespaceName, eventhubName, consumerGroupName) - return result.Response.StatusCode == 404 + return result.Response.StatusCode == http.StatusNotFound }, timeout, ).Should(BeTrue()) diff --git a/pkg/resourcemanager/eventhubs/hub_test.go b/pkg/resourcemanager/eventhubs/hub_test.go index 2779c2c9e62..c1451bda855 100644 --- a/pkg/resourcemanager/eventhubs/hub_test.go +++ b/pkg/resourcemanager/eventhubs/hub_test.go @@ -18,6 +18,7 @@ package eventhubs import ( "context" + "net/http" "time" model "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" @@ -71,7 +72,7 @@ var _ = Describe("Eventhub", func() { Eventually(func() bool { result, _ := eventHubManager.GetHub(context.Background(), rgName, eventhubNamespaceName, eventhubName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -88,7 +89,7 @@ var _ = Describe("Eventhub", func() { Eventually(func() bool { result, _ := eventHubManager.ListKeys(context.Background(), rgName, eventhubNamespaceName, eventhubName, authorizationRuleName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -97,7 +98,7 @@ var _ = Describe("Eventhub", func() { Eventually(func() bool { result, _ := eventHubManager.GetHub(context.Background(), rgName, eventhubNamespaceName, eventhubName) - return result.Response.StatusCode == 404 + return result.Response.StatusCode == http.StatusNotFound }, timeout, ).Should(BeTrue()) diff --git a/pkg/resourcemanager/eventhubs/namespace_test.go b/pkg/resourcemanager/eventhubs/namespace_test.go index 154261c0064..e4d399bfe63 100644 --- a/pkg/resourcemanager/eventhubs/namespace_test.go +++ b/pkg/resourcemanager/eventhubs/namespace_test.go @@ -18,6 +18,7 @@ package eventhubs import ( "context" + "net/http" "time" helpers "github.com/Azure/azure-service-operator/pkg/helpers" @@ -59,7 +60,7 @@ var _ = Describe("Namespace", func() { Eventually(func() bool { result, _ := eventHubNamespaceManager.GetNamespace(context.Background(), rgName, eventhubNamespaceName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -68,7 +69,7 @@ var _ = Describe("Namespace", func() { Eventually(func() bool { result, _ := eventHubNamespaceManager.GetNamespace(context.Background(), rgName, eventhubNamespaceName) - return result.Response.StatusCode == 404 || *result.ProvisioningState == "Deleting" + return result.Response.StatusCode == http.StatusNotFound || *result.ProvisioningState == "Deleting" }, timeout, ).Should(BeTrue()) diff --git a/pkg/resourcemanager/mock/eventhubs/consumergroup.go b/pkg/resourcemanager/mock/eventhubs/consumergroup.go index d8eb13e06b8..95980bc5ae5 100644 --- a/pkg/resourcemanager/mock/eventhubs/consumergroup.go +++ b/pkg/resourcemanager/mock/eventhubs/consumergroup.go @@ -19,6 +19,8 @@ package eventhubs import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" "github.com/Azure/go-autorest/autorest" @@ -81,12 +83,12 @@ func (manager *mockConsumerGroupManager) DeleteConsumerGroup(ctx context.Context }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("consumer group not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("consumer group not found") } manager.consumerGroupResources = append(groups[:index], groups[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } func (manager *mockConsumerGroupManager) GetConsumerGroup(ctx context.Context, resourceGroupName string, namespaceName string, eventHubName string, consumerGroupName string) (eventhub.ConsumerGroup, error) { diff --git a/pkg/resourcemanager/mock/eventhubs/hub.go b/pkg/resourcemanager/mock/eventhubs/hub.go index 97ca30e1095..2a9565b2eff 100644 --- a/pkg/resourcemanager/mock/eventhubs/hub.go +++ b/pkg/resourcemanager/mock/eventhubs/hub.go @@ -19,6 +19,8 @@ package eventhubs import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" pkghelpers "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" @@ -71,12 +73,12 @@ func (manager *mockEventHubManager) DeleteHub(ctx context.Context, resourceGroup }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("eventhub not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("eventhub not found") } manager.eventHubResources = append(hubs[:index], hubs[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } func (manager *mockEventHubManager) CreateHub(ctx context.Context, resourceGroupName string, namespaceName string, eventHubName string, messageRetentionInDays int32, partitionCount int32, captureDescription *eventhub.CaptureDescription) (eventhub.Model, error) { @@ -142,7 +144,7 @@ func (manager *mockEventHubManager) CreateOrUpdateAuthorizationRule(ctx context. hub.eventHubAccesses = append(hub.eventHubAccesses, eventHubAccess{ rule: parameters, keys: eventhub.AccessKeys{ - Response: helpers.GetRestResponse(200), + Response: helpers.GetRestResponse(http.StatusOK), PrimaryConnectionString: to.StringPtr(pkghelpers.RandomString(40)), SecondaryConnectionString: to.StringPtr(pkghelpers.RandomString(40)), AliasPrimaryConnectionString: to.StringPtr(pkghelpers.RandomString(40)), diff --git a/pkg/resourcemanager/mock/eventhubs/namespace.go b/pkg/resourcemanager/mock/eventhubs/namespace.go index 09dddd68590..cdccc4843c0 100644 --- a/pkg/resourcemanager/mock/eventhubs/namespace.go +++ b/pkg/resourcemanager/mock/eventhubs/namespace.go @@ -19,6 +19,8 @@ package eventhubs import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" "github.com/Azure/go-autorest/autorest" @@ -70,12 +72,12 @@ func (manager *mockEventHubNamespaceManager) DeleteNamespace(ctx context.Context }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("eventhub namespace not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("eventhub namespace not found") } manager.eventHubNamespaceResources = append(namespaces[:index], namespaces[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } func (manager *mockEventHubNamespaceManager) GetNamespace(ctx context.Context, resourceGroupName string, namespaceName string) (*eventhub.EHNamespace, error) { diff --git a/pkg/resourcemanager/mock/keyvaults/keyvault.go b/pkg/resourcemanager/mock/keyvaults/keyvault.go index eef0487419f..4acb2321bd9 100644 --- a/pkg/resourcemanager/mock/keyvaults/keyvault.go +++ b/pkg/resourcemanager/mock/keyvaults/keyvault.go @@ -19,6 +19,8 @@ package keyvaults import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2018-02-14/keyvault" pkghelpers "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" @@ -48,7 +50,7 @@ func findKeyVault(res []keyVaultResource, predicate func(keyVaultResource) bool) // CreateVault creates a new key vault func (manager *MockKeyVaultManager) CreateVault(ctx context.Context, groupName string, vaultName string, location string) (keyvault.Vault, error) { v := keyvault.Vault{ - Response: helpers.GetRestResponse(200), + Response: helpers.GetRestResponse(http.StatusOK), Properties: &keyvault.VaultProperties{}, ID: to.StringPtr(pkghelpers.RandomString(10)), Name: to.StringPtr(vaultName), @@ -77,12 +79,12 @@ func (manager *MockKeyVaultManager) DeleteVault(ctx context.Context, groupName s }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("key vault not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("key vault not found") } manager.keyVaultResources = append(vaults[:index], vaults[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } // Returns an existing keyvault instance @@ -96,7 +98,7 @@ func (manager *MockKeyVaultManager) GetVault(ctx context.Context, groupName stri if index == -1 { return keyvault.Vault{ - Response: helpers.GetRestResponse(404), + Response: helpers.GetRestResponse(http.StatusNotFound), }, errors.New("key vault not found") } diff --git a/pkg/resourcemanager/mock/resourcegroups/resourcegroup.go b/pkg/resourcemanager/mock/resourcegroups/resourcegroup.go index 91757ab0064..5de6ef15894 100644 --- a/pkg/resourcemanager/mock/resourcegroups/resourcegroup.go +++ b/pkg/resourcemanager/mock/resourcegroups/resourcegroup.go @@ -19,6 +19,8 @@ package resourcegroups import ( "context" "errors" + "net/http" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2017-05-10/resources" @@ -60,12 +62,12 @@ func (manager *MockResourceGroupManager) DeleteGroup(ctx context.Context, groupN }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("resource group not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("resource group not found") } manager.resourceGroups = append(groups[:index], groups[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } func (manager *MockResourceGroupManager) DeleteGroupAsync(ctx context.Context, groupName string) (resources.GroupsDeleteFuture, error) { @@ -81,8 +83,8 @@ func (manager *MockResourceGroupManager) CheckExistence(ctx context.Context, gro }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("resource group not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("resource group not found") } - return helpers.GetRestResponse(204), nil + return helpers.GetRestResponse(http.StatusNoContent), nil } diff --git a/pkg/resourcemanager/mock/storages/blob_container.go b/pkg/resourcemanager/mock/storages/blob_container.go index 74d07b7bce8..17352f062f6 100644 --- a/pkg/resourcemanager/mock/storages/blob_container.go +++ b/pkg/resourcemanager/mock/storages/blob_container.go @@ -19,6 +19,8 @@ package storages import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" "github.com/Azure/go-autorest/autorest" @@ -96,10 +98,10 @@ func (manager *mockBlobContainerManager) DeleteBlobContainer(ctx context.Context }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("blob container not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("blob container not found") } manager.blobContainerResource = append(containers[:index], containers[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } diff --git a/pkg/resourcemanager/mock/storages/storage.go b/pkg/resourcemanager/mock/storages/storage.go index 8fad50de5ad..ef08c96aa93 100644 --- a/pkg/resourcemanager/mock/storages/storage.go +++ b/pkg/resourcemanager/mock/storages/storage.go @@ -19,6 +19,8 @@ package storages import ( "context" "errors" + "net/http" + "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage" apiv1 "github.com/Azure/azure-service-operator/api/v1" "github.com/Azure/azure-service-operator/pkg/resourcemanager/mock/helpers" @@ -103,10 +105,10 @@ func (manager *mockStorageManager) DeleteStorage(ctx context.Context, resourceGr }) if index == -1 { - return helpers.GetRestResponse(404), errors.New("storage account not found") + return helpers.GetRestResponse(http.StatusNotFound), errors.New("storage account not found") } manager.storageResource = append(groups[:index], groups[index+1:]...) - return helpers.GetRestResponse(200), nil + return helpers.GetRestResponse(http.StatusOK), nil } diff --git a/pkg/resourcemanager/resourcegroups/resourcegroup_test.go b/pkg/resourcemanager/resourcegroups/resourcegroup_test.go index 2b92f15023b..ac5b71b0557 100644 --- a/pkg/resourcemanager/resourcegroups/resourcegroup_test.go +++ b/pkg/resourcemanager/resourcegroups/resourcegroup_test.go @@ -18,9 +18,11 @@ package resourcegroups import ( "context" - "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + "net/http" "time" + "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -59,7 +61,7 @@ var _ = Describe("ResourceGroups", func() { Eventually(func() bool { result, _ := resourceGroupManager.CheckExistence(context.Background(), resourcegroupName) - return result.Response.StatusCode == 204 + return result.Response.StatusCode == http.StatusNoContent }, timeout, ).Should(BeTrue()) @@ -68,7 +70,7 @@ var _ = Describe("ResourceGroups", func() { Eventually(func() bool { result, _ := GetGroup(context.Background(), resourcegroupName) - return result.Response.StatusCode == 404 || *result.Properties.ProvisioningState == "Deleting" + return result.Response.StatusCode == http.StatusNotFound || *result.Properties.ProvisioningState == "Deleting" }, timeout, ).Should(BeTrue()) diff --git a/pkg/resourcemanager/sqlclient/endtoend_test.go b/pkg/resourcemanager/sqlclient/endtoend_test.go index 119de4a2812..06115bc50a9 100644 --- a/pkg/resourcemanager/sqlclient/endtoend_test.go +++ b/pkg/resourcemanager/sqlclient/endtoend_test.go @@ -8,6 +8,7 @@ package sqlclient import ( "context" "fmt" + "net/http" "testing" "time" @@ -100,7 +101,7 @@ func TestCreateOrUpdateSQLServer(t *testing.T) { time.Sleep(time.Second) response, err := sdk.DeleteDB("testDB") if err == nil { - if response.StatusCode == 200 { + if response.StatusCode == http.StatusOK { util.PrintAndLog("db deleted") } } else { @@ -113,7 +114,7 @@ func TestCreateOrUpdateSQLServer(t *testing.T) { time.Sleep(time.Second) response, err := sdk.DeleteSQLServer() if err == nil { - if response.StatusCode == 200 { + if response.StatusCode == http.StatusOK { util.PrintAndLog("sql server deleted") break } diff --git a/pkg/resourcemanager/sqlclient/sqlclient_godsk.go b/pkg/resourcemanager/sqlclient/sqlclient_godsk.go index 2b0f0966439..06ad3ba4926 100644 --- a/pkg/resourcemanager/sqlclient/sqlclient_godsk.go +++ b/pkg/resourcemanager/sqlclient/sqlclient_godsk.go @@ -122,7 +122,7 @@ func (sdk GoSDKClient) DeleteDB(databaseName string) (result autorest.Response, if err != nil { result = autorest.Response{ Response: &http.Response{ - StatusCode: 200, + StatusCode: http.StatusOK, }, } return result, nil @@ -151,7 +151,7 @@ func (sdk GoSDKClient) DeleteSQLServer() (result autorest.Response, err error) { if err != nil { result = autorest.Response{ Response: &http.Response{ - StatusCode: 200, + StatusCode: http.StatusOK, }, } return result, nil diff --git a/pkg/resourcemanager/storages/blob_container_test.go b/pkg/resourcemanager/storages/blob_container_test.go index 54753ef3667..9ef04e77b4b 100644 --- a/pkg/resourcemanager/storages/blob_container_test.go +++ b/pkg/resourcemanager/storages/blob_container_test.go @@ -18,12 +18,14 @@ package storages import ( "context" + "net/http" + "time" + apiv1 "github.com/Azure/azure-service-operator/api/v1" "github.com/Azure/azure-service-operator/pkg/helpers" "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "time" ) var _ = Describe("Blob Container", func() { @@ -62,7 +64,7 @@ var _ = Describe("Blob Container", func() { Eventually(func() bool { result, _ := tc.StorageManagers.BlobContainer.GetBlobContainer(context.Background(), tc.ResourceGroupName, storageAccountName, containerName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -71,7 +73,7 @@ var _ = Describe("Blob Container", func() { Eventually(func() bool { result, _ := tc.StorageManagers.BlobContainer.GetBlobContainer(context.Background(), tc.ResourceGroupName, storageAccountName, containerName) - return result.Response.StatusCode == 404 + return result.Response.StatusCode == http.StatusNotFound }, timeout, ).Should(BeTrue()) diff --git a/pkg/resourcemanager/storages/storage_test.go b/pkg/resourcemanager/storages/storage_test.go index a5905ec42e5..94894897180 100644 --- a/pkg/resourcemanager/storages/storage_test.go +++ b/pkg/resourcemanager/storages/storage_test.go @@ -18,10 +18,12 @@ package storages import ( "context" + "net/http" + "time" + apiv1 "github.com/Azure/azure-service-operator/api/v1" "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" "github.com/Azure/go-autorest/autorest/to" - "time" "github.com/Azure/azure-service-operator/pkg/helpers" . "github.com/onsi/ginkgo" @@ -62,7 +64,7 @@ var _ = Describe("Storage Account", func() { Eventually(func() bool { result, _ := storageManagers.Storage.GetStorage(context.Background(), tc.ResourceGroupName, storageAccountName) - return result.Response.StatusCode == 200 + return result.Response.StatusCode == http.StatusOK }, timeout, ).Should(BeTrue()) @@ -71,7 +73,7 @@ var _ = Describe("Storage Account", func() { Eventually(func() bool { result, _ := storageManagers.Storage.GetStorage(context.Background(), tc.ResourceGroupName, storageAccountName) - return result.Response.StatusCode == 404 + return result.Response.StatusCode == http.StatusNotFound }, timeout, ).Should(BeTrue()) }) diff --git a/pkg/resourcemanager/storages/suite_test.go b/pkg/resourcemanager/storages/suite_test.go index 253fbbb5e74..8343a79b54e 100644 --- a/pkg/resourcemanager/storages/suite_test.go +++ b/pkg/resourcemanager/storages/suite_test.go @@ -16,9 +16,11 @@ limitations under the License. package storages import ( - "github.com/Azure/azure-service-operator/pkg/helpers" + "net/http" "testing" + "github.com/Azure/azure-service-operator/pkg/helpers" + resourcemanagerconfig "github.com/Azure/azure-service-operator/pkg/resourcemanager/config" resourcegroupsresourcemanager "github.com/Azure/azure-service-operator/pkg/resourcemanager/resourcegroups" @@ -76,7 +78,7 @@ var _ = BeforeSuite(func() { // create resourcegroup for this suite result, _ := ressourceGroupManager.CheckExistence(context.Background(), tc.ResourceGroupName) - if result.Response.StatusCode != 204 { + if result.Response.StatusCode != http.StatusNoContent { _, _ = tc.ResourceGroupManager.CreateGroup(context.Background(), tc.ResourceGroupName, tc.ResourceGroupLocation) } })