Tests/Import-ARMtemplate.Tests.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
#$here = Split-Path -Parent $MyInvocation.MyCommand.Path #$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' #. "$here\$sut" $modulePath = Split-Path $PSScriptRoot -Parent $modulepath = Join-Path -Path $modulePath -ChildPath posharm.psd1 Import-Module $modulePath Describe "Import-ARMtemplate" { $modulepath = Split-Path $PSScriptRoot -Parent $testfilePath = Join-Path -Path $modulepath -ChildPath "TestFiles\simplevm.json" $jsonString = Get-Content -Path $testfilePath -Encoding UTF8 -Raw It "JSON string should not be null" { $jsonString | Should not be $null } It "TestFilePath should exists" { Test-Path -Path $testfilePath | Should be $true } Context "After module loaded" { It "Should not have an ARM template after module Import" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | should be 0 } } Context "Importing template from file" { Import-ARMtemplate -FileName $testfilePath It "Should import a template" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | Should BeGreaterThan 0 } } Remove-Module PoshARM Import-Module $modulePath Context "Importing template from file with pipeline" { Get-ChildItem -path $testfilePath | Import-ARMtemplate It "Should import a template" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | Should BeGreaterThan 0 } } Remove-Module PoshARM Import-Module $modulePath Context "Importing template from a string variable" { Import-ARMtemplate -JsonString $jsonString It "Should import a template" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | Should BeGreaterThan 0 } } Remove-Module PoshARM Import-Module $modulePath Context "Importing template from a string variable with pipeline" { $jsonString | Import-ARMtemplate It "Should import a template" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | Should BeGreaterThan 0 } } Remove-Module PoshARM Import-Module $modulePath Context "Importing template from clipboard" { $jsonString | Set-Clipboard Get-Clipboard | Import-ARMtemplate It "Should import a template" { ((Get-ARMtemplate).PSobject.Properties | Measure-Object).Count | Should BeGreaterThan 0 } } } Remove-Module -name posharm -ErrorAction SilentlyContinue |