Update tests to new format

This commit is contained in:
Wes Carroll
2019-07-20 20:01:02 -04:00
parent 6b1486b74d
commit 047e701f55
2 changed files with 15 additions and 19 deletions
-1
View File
@@ -49,4 +49,3 @@ Describe $global:function -Tag 'Unit', 'Source', 'Built' {
Remove-Variable -Name here -Scope Global Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global Remove-Variable -Name function -Scope Global
+14 -17
View File
@@ -1,24 +1,21 @@
#Requires -Modules Pester #Requires -Modules Pester
$moduleFileName = "ZertoApiWrapper.psd1" $global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper") $global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
$file = Get-ChildItem "$here\$sut"
$modulePath = $here -replace "Public", ""
$moduleFile = Get-ChildItem "$modulePath\$moduleFileName"
Get-Module -Name ZertoApiWrapper | Remove-Module -Force
Import-Module $moduleFile -Force
Describe $file.BaseName -Tag 'Unit' { Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "is valid Powershell (Has no script errors)" { Context "$global:function::Parameter Unit Tests" {
$contents = Get-Content -Path $file -ErrorAction Stop
$errors = $null It "has a non-mandatory string parameter for the datacenterIdentifier" {
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors) Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier
$errors | Should -HaveCount 0 Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier -Type String[]
}
} }
It "has a non-mandatory string parameter for the datacenterIdentifier" { Context "$global:function::Parameter Functional Tests" {
Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier
Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier -Type String[]
} }
} }
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global