Skip to content

Commit 06ef7f8

Browse files
author
Harsh Patel
committed
Finished Test-NewAndSetSubscriptionDeploymentStackWithTemplateSpec [Needs testing]
1 parent 8b872f6 commit 06ef7f8

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

src/Resources/Resources.Test/ScenarioTests/DeploymentStackTests.ps1

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function Test-NewResourceGroupDeploymentStack
257257

258258
<#
259259
.SYNOPSIS
260-
Tests NEW and Set operation on deploymentStacks at the RG scope using template specs
260+
Tests NEW and SET operation on deploymentStacks at the RG scope using template specs
261261
#>
262262

263263
function Test-NewAndSetResourceGroupDeploymentStackWithTemplateSpec
@@ -297,6 +297,48 @@ function Test-NewAndSetResourceGroupDeploymentStackWithTemplateSpec
297297
}
298298
}
299299

300+
<#
301+
.SYNOPSIS
302+
Tests NEW and SET operation on deploymentStacks at the subscription scope using template specs
303+
#>
304+
305+
function Test-NewAndSetSubscriptionDeploymentStackWithTemplateSpec
306+
{
307+
# Setup
308+
$rgname = Get-ResourceGroupName
309+
$rname = Get-ResourceName
310+
$rglocation = "West US 2"
311+
312+
try {
313+
# Prepare
314+
New-AzResourceGroup -Name $rgname -Location $rglocation
315+
316+
$sampleTemplateJson = Get-Content -Raw -Path "subscription_level_template.json"
317+
$basicCreatedTemplateSpec = New-AzTemplateSpec -ResourceGroupName $rgname -Name $rname -Location $rgLocation -Version "v1" -TemplateJson $sampleTemplateJson
318+
319+
$resourceId = $basicCreatedTemplateSpec.Id + "/versions/v1"
320+
321+
# Test - New-AzSubscriptionDeploymentStacks using templateSpecs
322+
$deployment = New-AzResourceGroupDeploymentStacks -Name $rname -TemplateSpec $resourceId -ParameterFile "subscription_level_parameters.json"
323+
324+
# Assert
325+
Assert-AreEqual Succeeded $deployment.ProvisioningState
326+
327+
# Test - Set-AzSubscriptionDeploymentStacks using templateSpecs
328+
$deployment = Set-AzResourceGroupDeploymentStacks -Name $rname -TemplateSpec $resourceId -ParameterFile "sampleTemplateParams.json" -Location $rglocation -updateBehavior "detach"
329+
330+
# Assert
331+
Assert-AreEqual Succeeded $deployment.ProvisioningState
332+
333+
}
334+
335+
finally
336+
{
337+
# Cleanup
338+
Clean-ResourceGroup $rgname
339+
}
340+
}
341+
300342

301343
<#
302344
.SYNOPSIS

0 commit comments

Comments
 (0)