Created
January 3, 2018 18:16
-
-
Save aw230012/133ce7c46f71630c9795c1ca94d14cf0 to your computer and use it in GitHub Desktop.
New Recovery Vault Pester Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Describe 'New-RecoveryVault Tests' { | |
$configurationFile = "$PSScriptRoot\\..\\Data\\RecoveryVaultConfiguration.json" | |
$configurationData = (Get-Content $configurationFile -Raw | ConvertFrom-Json).ConfigurationItems | |
Context 'Resource Group Tests' { | |
$rg = Get-AzureRmResourceGroup -Name $configurationData.ResourceGroup.Name | |
It 'Resource Group Exists' { | |
$rg | Select-Object -ExpandProperty ResourceGroupName | Should Be $configurationData.ResourceGroup.Name | |
} | |
It 'Is Correct Location' { | |
$expectedValue = $configurationData.Location.Name -replace ' ', '' | |
$rg.Location | Should Be $expectedValue | |
} | |
} | |
Context 'Recovery Vault Tests' { | |
$vault = Get-AzureRmRecoveryServicesVault -ResourceGroupName $configurationData.ResourceGroup.Name -Name $configurationData.RecoveryVault.Name | |
Set-AzureRmRecoveryServicesVaultContext -Vault $vault | |
$policy = Get-AzureRmRecoveryServicesBackupProtectionPolicy -Name $configurationData.RecoveryVault.Policy.Name | |
It 'Recovery Vault Exists' { | |
$vault | Select-Object -ExpandProperty Name | Should Be $configurationData.RecoveryVault.Name | |
} | |
It 'Backup Policy Exists' { | |
$policy | Select-Object -ExpandProperty Name | Should Be $configurationData.RecoveryVault.Policy.Name | |
} | |
} | |
} |
you have only 1 parameters file but typically you may want to test your deployment with multiple parameter files, each having a particular combination of values. How do you achieve that? I tried using -Testcases in It block but I am facing some issues
Regards
Badal
you could use a param() block in the beginning to pass in a different configurations file. That way you could reuse the tests for different configurations.
param(
[string] $ConfigurationFile = "$PSScriptRoot\\..\\Data\\RecoveryVaultConfiguration.json"
)
...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you have only 1 parameters file but typically you may want to test your deployment with multiple parameter files, each having a particular combination of values. How do you achieve that? I tried using -Testcases in It block but I am facing some issues
Regards
Badal