Skip to content

Instantly share code, notes, and snippets.

@pburkholder
Last active April 6, 2017 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pburkholder/0797f04a63182f6b9dc2596969ae635d to your computer and use it in GitHub Desktop.
Save pburkholder/0797f04a63182f6b9dc2596969ae635d to your computer and use it in GitHub Desktop.
Pester comparison desired state (template) to actual
# Exploring AzureRM json descriptors for testing
# We create a desiredification by running Deploy-DevVnetVA.ps1 and having it stop after writing the template,
# 'desired-DevNetVA.json'
# We determin actual state by exporting the AzureRM Resource group:
# Export-AzureRmResourceGroup -ResourceGroupName DevVnetVA -Path $pwd/actual-DevVnetVA.json
Describe "DevNetVa" {
BeforeEach {
$actual=Get-Content ./actual-DevVnetVA.json | ConvertFrom-Json
$desired=Get-Content ./desired-DevVnetVA.json | ConvertFrom-Json
}
Context "actualDevVnetVA" {
It "Has 3 resources " {
$actual.resources.length | Should be 3
}
}
Context "desiredDevVnetVA" {
It "Has 3 resources " {
$desired.resources.length | Should be 3
}
}
Context "networkSecurityGroups" {
$actual_nsg = $actual.resources | where {$_.type -Match "networkSecurityGroup"}
$desired_nsg = $desired.resources | where {$_.type -Match "networkSecurityGroup"}
It "actual is not an array" {
$actual_nsg.GetType().IsArray | Should Be $False
}
It "desired is not an array" {
$desired_nsg.GetType().IsArray | Should Be $False
}
}
Context "routeTables" {
$actual_routeTables = $actual.resources | where {$_.type -Match "routeTables"}
$desired_routeTables = $desired.resources | where {$_.type -Match "routeTables"}
It "are each just one routeTable" {
$actual_routeTables.GetType().IsArray | Should Be $False
$desired_routeTables.GetType().IsArray | Should Be $False
}
It "comprises 3 UDRs" {
$actual_routeTables.properties.routes.length | Should be 3
$desired_routeTables.properties.routes.length | Should be 3
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment