diff --git a/src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/ResourceClientTests.cs b/src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/ResourceClientTests.cs index 922c69bc2a84..bb420a7c6af2 100644 --- a/src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/ResourceClientTests.cs +++ b/src/ResourceManager/Resources/Commands.Resources.Test/Models.ResourceGroups/ResourceClientTests.cs @@ -878,96 +878,6 @@ public void GetResourceWithIncorrectTypeThrowsException() Assert.Throws(() => resourcesClient.FilterPSResources(parameters)); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void NewResourceGroupFailsWithInvalidDeployment() - { - Uri templateUri = new Uri("http://templateuri.microsoft.com"); - Deployment deploymentFromGet = new Deployment(); - Deployment deploymentFromValidate = new Deployment(); - CreatePSResourceGroupParameters parameters = new CreatePSResourceGroupParameters() - { - ResourceGroupName = resourceGroupName, - Location = resourceGroupLocation, - DeploymentName = deploymentName, - TemplateFile = templateFile, - StorageAccountName = storageAccountName, - ConfirmAction = ConfirmAction - }; - resourceGroupMock.Setup(f => f.CheckExistenceAsync(parameters.ResourceGroupName, new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new ResourceGroupExistsResult - { - Exists = false - })); - - resourceGroupMock.Setup(f => f.CreateOrUpdateAsync( - parameters.ResourceGroupName, - It.IsAny(), - new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new ResourceGroupCreateOrUpdateResult - { - ResourceGroup = new ResourceGroupExtended() { Name = parameters.ResourceGroupName, Location = parameters.Location } - })); - resourceGroupMock.Setup(f => f.GetAsync(resourceGroupName, new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new ResourceGroupGetResult - { - ResourceGroup = new ResourceGroupExtended() { Location = resourceGroupLocation } - })); - deploymentsMock.Setup(f => f.CreateOrUpdateAsync(resourceGroupName, deploymentName, It.IsAny(), new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new DeploymentOperationsCreateResult - { - RequestId = requestId - })) - .Callback((string name, string dName, Deployment bDeploy, CancellationToken token) => { deploymentFromGet = bDeploy; }); - deploymentsMock.Setup(f => f.GetAsync(resourceGroupName, deploymentName, new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new DeploymentGetResult - { - Deployment = new DeploymentExtended() - { - Name = deploymentName, - Properties = new DeploymentPropertiesExtended() - { - Mode = DeploymentMode.Incremental, - ProvisioningState = ProvisioningState.Succeeded - }, - } - })); - deploymentsMock.Setup(f => f.ValidateAsync(resourceGroupName, It.IsAny(), It.IsAny(), new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new DeploymentValidateResponse - { - Error = new ResourceManagementErrorWithDetails() - { - Code = "404", - Message = "Awesome error message", - Target = "Bad deployment" - } - })) - .Callback((string rg, string dn, Deployment d, CancellationToken c) => { deploymentFromValidate = d; }); - SetupListForResourceGroupAsync(parameters.ResourceGroupName, new List() { new GenericResourceExtended() { Name = "website" } }); - deploymentOperationsMock.Setup(f => f.ListAsync(resourceGroupName, deploymentName, null, new CancellationToken())) - .Returns(Task.Factory.StartNew(() => new DeploymentOperationsListResult - { - Operations = new List() - { - new DeploymentOperation() - { - OperationId = Guid.NewGuid().ToString(), - Properties = new DeploymentOperationProperties() - { - ProvisioningState = ProvisioningState.Succeeded, - TargetResource = new TargetResource() - { - ResourceName = resourceName, - ResourceType = "Microsoft.Website" - } - } - } - } - })); - - Assert.Throws(() => resourcesClient.CreatePSResourceGroup(parameters)); - } - [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] public void TestTemplateShowsErrorMessage() @@ -1304,9 +1214,6 @@ public void NewResourceGroupWithDeploymentSucceeds() Assert.Equal(DeploymentMode.Incremental, deploymentFromGet.Properties.Mode); Assert.NotNull(deploymentFromGet.Properties.Template); - Assert.Equal(DeploymentMode.Incremental, deploymentFromValidate.Properties.Mode); - Assert.NotNull(deploymentFromValidate.Properties.Template); - progressLoggerMock.Verify( f => f(string.Format("Resource {0} '{1}' provisioning status is {2}", "Microsoft.Website", @@ -1417,8 +1324,6 @@ public void CreatesResourceGroupWithDeploymentFromTemplateParameterObject() // Skip: Test produces different outputs since hashtable order is not guaranteed. //EqualsIgnoreWhitespace(File.ReadAllText(templateParameterFile), deploymentFromGet.Parameters); - Assert.Equal(DeploymentMode.Incremental, deploymentFromValidate.Properties.Mode); - Assert.NotNull(deploymentFromValidate.Properties.Template); // Skip: Test produces different outputs since hashtable order is not guaranteed. //EqualsIgnoreWhitespace(File.ReadAllText(templateParameterFile), deploymentFromValidate.Parameters); @@ -1524,9 +1429,6 @@ public void ShowsFailureErrorWhenResourceGroupWithDeploymentFails() Assert.Equal(DeploymentMode.Incremental, deploymentFromGet.Properties.Mode); Assert.NotNull(deploymentFromGet.Properties.Template); - Assert.Equal(DeploymentMode.Incremental, deploymentFromValidate.Properties.Mode); - Assert.NotNull(deploymentFromValidate.Properties.Template); - errorLoggerMock.Verify( f => f(string.Format("Resource {0} '{1}' failed with message '{2}'", "Microsoft.Website", @@ -1632,9 +1534,6 @@ public void ExtractsErrorMessageFromFailedDeploymentOperation() Assert.Equal(DeploymentMode.Incremental, deploymentFromGet.Properties.Mode); Assert.NotNull(deploymentFromGet.Properties.Template); - Assert.Equal(DeploymentMode.Incremental, deploymentFromValidate.Properties.Mode); - Assert.NotNull(deploymentFromValidate.Properties.Template); - errorLoggerMock.Verify( f => f(string.Format("Resource {0} '{1}' failed with message '{2}'", "Microsoft.Website", diff --git a/src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs b/src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs index d8d71cac373f..98d8fe40b98f 100644 --- a/src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs +++ b/src/ResourceManager/Resources/Commands.Resources/Models.ResourceGroups/ResourceClient.ResourceManager.cs @@ -303,20 +303,6 @@ public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroup { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode); - TemplateValidationInfo validationInfo = CheckBasicDeploymentErrors(parameters.ResourceGroupName, parameters.DeploymentName, deployment); - - if (validationInfo.Errors.Count != 0) - { - int counter = 1; - string errorFormat = "Error {0}: Code={1}; Message={2}\r\n"; - StringBuilder errorsString = new StringBuilder(); - validationInfo.Errors.ForEach(e => errorsString.AppendFormat(errorFormat, counter++, e.Code, e.Message)); - throw new ArgumentException(errorsString.ToString()); - } - else - { - WriteVerbose(ProjectResources.TemplateValid); - } if (!string.IsNullOrEmpty(parameters.StorageAccountName)) {