Skip to content

Commit 26eeb2a

Browse files
committed
Add a scenario test to ensure nested errors are displayed
1 parent 3299209 commit 26eeb2a

File tree

5 files changed

+601
-0
lines changed

5 files changed

+601
-0
lines changed

src/ResourceManager/Resources/Commands.Resources.Test/Commands.Resources.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@
336336
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests\TestNestedDeploymentFromTemplateFile.json">
337337
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
338338
</None>
339+
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests\TestNestedErrorsDisplayed.json">
340+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
341+
</None>
339342
<None Include="SessionRecords\Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests\TestNewDeploymentFromTemplateFile.json">
340343
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
341344
</None>
@@ -583,6 +586,9 @@
583586
<None Include="sampleNestedTemplateParams.json">
584587
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
585588
</None>
589+
<None Include="sampleTemplateThrowsNestedErrors.json">
590+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
591+
</None>
586592
</ItemGroup>
587593
<ItemGroup>
588594
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/DeploymentTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ public void TestSaveDeploymentTemplateFile()
4242
ResourcesController.NewInstance.RunPsTest("Test-SaveDeploymentTemplateFile");
4343
}
4444

45+
[Fact]
46+
public void TestNestedErrorsDisplayed()
47+
{
48+
ResourcesController.NewInstance.RunPsTest("Test-NestedErrorsDisplayed");
49+
}
50+
4551
[Fact(Skip = "Fix acquisition of TenantId in KeyVault Test.")]
4652
public void TestNewDeploymentWithKeyVaultReference()
4753
{

src/ResourceManager/Resources/Commands.Resources.Test/ScenarioTests/DeploymentTests.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ function Test-NewDeploymentFromTemplateFile
6767
}
6868
}
6969

70+
<#
71+
.SYNOPSIS
72+
Tests nested errors displayed when temployment put fails.
73+
#>
74+
function Test-NestedErrorsDisplayed
75+
{
76+
# Setup
77+
$rgname = Get-ResourceGroupName
78+
$rname = Get-ResourceName
79+
$rglocation = "EastUS"
80+
81+
try
82+
{
83+
# Test
84+
$ErrorActionPreference = "SilentlyContinue"
85+
$Error.Clear()
86+
New-AzureRmResourceGroup -Name $rgname -Location $rglocation
87+
New-AzureRmResourceGroupDeployment -Name $rname -ResourceGroupName $rgname -TemplateFile sampleTemplateThrowsNestedErrors.json
88+
}
89+
catch
90+
{
91+
Assert-True { $Error[1].Contains("Storage account name must be between 3 and 24 characters in length") }
92+
}
93+
finally
94+
{
95+
# Cleanup
96+
Clean-ResourceGroup $rgname
97+
}
98+
}
99+
70100
<#
71101
.SYNOPSIS
72102
Tests nested deployment.

0 commit comments

Comments
 (0)