@@ -22,6 +22,7 @@ Describe "Repository" {
2222 $script :tenantId = $env: ARM_TENANT_ID
2323 $script :subscriptionId = $env: ARM_SUBSCRIPTION_ID
2424 $otherSubscription = Get-AzSubscription | Where-Object { $_.Id -ne $script :subscriptionId } | Sort-Object Name - Descending | Select-Object Id - First 2
25+ $skipSubscription = Get-AzSubscription | Where-Object { $_.Id -ne $script :subscriptionId -and $_.Id -notin $otherSubscription.Id } | Sort-Object Name - Descending | Select-Object Id - First 1
2526
2627 # Validate that the runtime variables are set as they are used to authenticate the Azure session.
2728
@@ -201,6 +202,7 @@ Describe "Repository" {
201202 Set-PSFConfig - FullName AzOps.Core.State - Value $generatedRoot
202203 Set-PSFConfig - FullName AzOps.Core.SkipLock - Value $false
203204 Set-PSFConfig - FullName AzOps.Core.SkipChildResource - Value $false
205+ Set-PSFConfig - FullName AzOps.Core.SkipSubscription - Value @ ($skipSubscription.Id )
204206 Set-PSFConfig - FullName AzOps.Core.DefaultDeploymentRegion - Value " northeurope"
205207 $deploymentLocationId = (Get-FileHash - Algorithm SHA256 - InputStream ([IO.MemoryStream ]::new([byte []][char []](Get-PSFConfigValue - FullName ' AzOps.Core.DefaultDeploymentRegion' )))).Hash.Substring(0 , 4 )
206208
@@ -1363,6 +1365,7 @@ Describe "Repository" {
13631365 Get-AzPolicyAssignment - Id $script :policyAssignmentsDeletion.Id - ErrorAction SilentlyContinue | Should - Be $Null
13641366 }
13651367 # endregion
1368+
13661369 # region AzOps Managed DeploymentStacks
13671370 It " Deploy and Delete AzOps Managed DeploymentStacks at Resource Group Scope" {
13681371 Set-PSFConfig - FullName AzOps.Core.CustomTemplateResourceDeletion - Value $true
@@ -1457,6 +1460,27 @@ Describe "Repository" {
14571460 }
14581461 }
14591462 # endregion
1463+
1464+ # region SkipSubscription Filter
1465+ It " Should have skipped subscription file present but no child resources" {
1466+ # Check that the skipped subscription file exists
1467+ $skippedSubscriptionFiles = $filePaths | Where-Object Name -eq " microsoft.subscription_subscriptions-$ ( ($skipSubscription.Id ).toLower()) .json"
1468+ $skippedSubscriptionFiles.Count | Should - Be 1
1469+
1470+ # Get the directory of the skipped subscription
1471+ $skippedSubscriptionDirectory = ($skippedSubscriptionFiles ).Directory
1472+
1473+ # Check that the directory exists
1474+ Test-Path - Path $skippedSubscriptionDirectory | Should - BeTrue
1475+
1476+ # Get all items in the subscription directory
1477+ $allItems = Get-ChildItem - Path $skippedSubscriptionDirectory - Recurse
1478+
1479+ # Should only have the subscription file itself, nothing else
1480+ $allItems.Count | Should - Be 1
1481+ $allItems [0 ].Name | Should - Be " microsoft.subscription_subscriptions-$ ( ($skipSubscription.Id ).toLower()) .json"
1482+ }
1483+ # endregion
14601484 }
14611485
14621486 AfterAll {
0 commit comments