Update tests to new format

This commit is contained in:
Wes Carroll
2019-07-21 11:54:28 -04:00
parent 6df14f7a8d
commit 202c865fe8
2 changed files with 35 additions and 40 deletions
@@ -1,28 +1,25 @@
#Requires -Modules Pester
$moduleFileName = "ZertoApiWrapper.psd1"
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
$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
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $file.BaseName -Tag 'Unit' {
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "is valid Powershell (Has no script errors)" {
$contents = Get-Content -Path $file -ErrorAction Stop
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
$errors | Should -HaveCount 0
}
Context "$global:function::Parameter Unit Tests" {
Context "$($file.BaseName)::Parameter Unit Tests" {
it "$global:function should have exactly 15 parameters defined" {
(get-command $global:function).Parameters.Count | Should -Be 12
}
it "has a mandatory string parameter for the vpgName" {
Get-Command $file.BaseName | Should -HaveParameter vpgName
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[]
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory
Get-Command $global:function | Should -HaveParameter vpgName
Get-Command $global:function | Should -HaveParameter vpgName -Type string[]
Get-Command $global:function | Should -HaveParameter vpgName -Mandatory
}
}
}
Context "$global:function::Parameter Functional Tests" {
}
}
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global
+18 -20
View File
@@ -1,28 +1,26 @@
#Requires -Modules Pester
$moduleFileName = "ZertoApiWrapper.psd1"
$here = (Split-Path -Parent $MyInvocation.MyCommand.Path).Replace("Tests", "ZertoApiWrapper")
$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
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $file.BaseName -Tag 'Unit' {
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
It "is valid Powershell (Has no script errors)" {
$contents = Get-Content -Path $file -ErrorAction Stop
$errors = $null
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
$errors | Should -HaveCount 0
}
Context "$global:function::Parameter Unit Tests" {
Context "$($file.BaseName)::Parameter Unit Tests" {
it "$global:function should have exactly 15 parameters defined" {
(get-command $global:function).Parameters.Count | Should -Be 12
}
it "has a mandatory string parameter for the vpgName" {
Get-Command $file.BaseName | Should -HaveParameter vpgName
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type string[]
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory
Get-Command $global:function | Should -HaveParameter vpgName
Get-Command $global:function | Should -HaveParameter vpgName -Type string[]
Get-Command $global:function | Should -HaveParameter vpgName -Mandatory
}
}
}
Context "$global:function::Parameter Functional Tests" {
}
}
Remove-Variable -Name here -Scope Global
Remove-Variable -Name function -Scope Global