Merge pull request #42 from ZertoPublic/UpdateTests
Update Testing Methods
This commit is contained in:
+3
-2
@@ -1,7 +1,8 @@
|
||||
|
||||
*.zip
|
||||
temp/*
|
||||
Tests/Public/TestResults.xml
|
||||
Tests/TestResults.xml
|
||||
BuiltTestResults.xml
|
||||
SourceTestResults.xml
|
||||
publish/*
|
||||
CodeCoverage.xml
|
||||
scratch
|
||||
|
||||
@@ -10,3 +10,7 @@
|
||||
|
||||
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/36) where the Zerto Analytics Rest Request function was not checking for the token before attempting a connection.
|
||||
* Fixed an [issue](https://github.com/ZertoPublic/ZertoApiWrapper/issues/40) where the `Get-ZAVpg` method would return a 404 error when a `-vpgIdentifier` parameter was specified.
|
||||
|
||||
### General Updates
|
||||
|
||||
* Updated the way that tests are invoked and parsed to ensure that both source and built module files are tested. This will ensure that what is being shipped passes all tests along with testing of the source files.
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#Requires -Modules Pester
|
||||
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
|
||||
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "have a mandatory parameter for the Input Object" {
|
||||
Get-Command $global:function | Should -HaveParameter InputObject -Mandatory -Type PSCustomObject
|
||||
}
|
||||
|
||||
it "Input Object should not accecpt a Null or Empty value" {
|
||||
$myObj = [PSCustomObject]@{ }
|
||||
{ Get-Map -InputObject $myObj -Key "Key" -Value "Value" } | Should Throw
|
||||
{ Get-Map -InputObject $null -Key "Key" -Value "Value" } | Should Throw
|
||||
{ Get-Map -InputObject "" -Key "Key" -Value "Value" } | Should Throw
|
||||
}
|
||||
|
||||
it "have a mandatory string parameter for the Map Key" {
|
||||
Get-Command $global:function | Should -HaveParameter Key -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "The Map variable should not accecpt a Null or Empty value" {
|
||||
$myObj = [PSCustomObject]@{one = 1; two = 2 }
|
||||
{ Get-Map -InputObject $myObj -Key "" -Value "Value" } | Should Throw
|
||||
{ Get-Map -InputObject $null -Key $null -Value "Value" } | Should Throw
|
||||
{ Get-Map -InputObject $myObj -Key 1 -Value "Value" } | Should Throw
|
||||
}
|
||||
|
||||
it "The Value variable should not accecpt a Null or Empty value" {
|
||||
$myObj = [PSCustomObject]@{one = 1; two = 2 }
|
||||
{ Get-Map -InputObject $myObj -Key "Key" -Value "" } | Should Throw
|
||||
{ Get-Map -InputObject $myObj -Key "Key" -Value $null } | Should Throw
|
||||
{ Get-Map -InputObject $myObj -Key "Key" -Value 1 } | Should Throw
|
||||
}
|
||||
|
||||
it "have a mandatory string parameter for the Map Value" {
|
||||
Get-Command $global:function | Should -HaveParameter Value -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "should have an Output type of Hashtable" {
|
||||
(Get-Command $global:function).OutputType.Name | Should -Match "Hashtable"
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Function Tests" {
|
||||
$myObj = Get-Content "$global:here/Mocks/ProtectedVMs.json" | ConvertFrom-Json
|
||||
BeforeEach {
|
||||
$MyMap = Get-Map -InputObject $MyObj -Key "vmIdentifier" -Value "vmName"
|
||||
}
|
||||
it "Returned object should be a hashtable" {
|
||||
$myMap | Should -BeOfType Hashtable
|
||||
}
|
||||
|
||||
it "should return a hashtable with 3 entries" {
|
||||
$myMap.count | should -Be 3
|
||||
}
|
||||
|
||||
it "should be properly mapped" {
|
||||
$myMap["vmid.12"] | Should -Be "ExchangeMailbox"
|
||||
$myMap["vmid.13"] | Should -Be "ExchangeApplication"
|
||||
$myMap["vmid.14"] | Should -Be "ExchangeWeb"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
@@ -1,30 +1,74 @@
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$file = Get-ChildItem "$filePath\$fileName"
|
||||
#Requires -Modules Pester
|
||||
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
|
||||
|
||||
. $file.FullName
|
||||
$singleBoolItemTest = @{"BoolItem" = $True}
|
||||
$oneItemTest = @{"OneItem" = "Test"}
|
||||
$twoItemTest = @{"OneItem" = "Test"; "SecondItem" = "Yours"}
|
||||
$boolItemTest = @{"OneItem" = "Test"; "BoolItem" = $true}
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
it "file should exist" {
|
||||
$file.Fullname | should exist
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "has a mandatory hashtable parameter for the filterTable" {
|
||||
Get-Command $global:function | Should -HaveParameter filterTable -Mandatory -Type Hashtable
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file.Fullname -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
It "FilterTable should not accecpt a Null or Empty parameter" {
|
||||
{ Get-ZertoApiFilter -filtertable (@{ }) } | Should Throw
|
||||
{ Get-ZertoApiFilter -filtertable "" } | Should Throw
|
||||
{ Get-ZertoApiFilter -filtertable $null } | Should Throw
|
||||
}
|
||||
|
||||
it "should have an Output type of String" {
|
||||
(Get-Command $global:function).OutputType.Name | Should -Match "String"
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Function Unit Tests" {
|
||||
BeforeAll {
|
||||
$singleBoolItemTest = @{"BoolItem" = $True }
|
||||
$oneItemTest = @{ OneItem = "Test" }
|
||||
$twoItemTest = @{
|
||||
OneItem = "Test"
|
||||
SecondItem = "Yours"
|
||||
}
|
||||
$commonParamTest = @{
|
||||
Debug = $True
|
||||
ErrorAction = "Stop"
|
||||
ErrorVariable = "ErrVar"
|
||||
InformationAction = "Continue"
|
||||
InformationVariable = "InfoVar"
|
||||
OutVariable = "OutVar"
|
||||
OutBuffer = "OutBuff"
|
||||
PipelineVariable = "PipeVar"
|
||||
Verbose = $false
|
||||
WarningAction = "SilentlyContinue"
|
||||
WarningVariable = "WarnVar"
|
||||
WhatIf = $True
|
||||
Confirm = $false
|
||||
OneItem = "Test"
|
||||
}
|
||||
}
|
||||
|
||||
it "converts bool to text" {
|
||||
Get-ZertoApiFilter -filtertable $singleBoolItemTest | should -Be "?BoolItem=True"
|
||||
}
|
||||
|
||||
it "one item test" {
|
||||
Get-ZertoApiFilter -filtertable $oneItemTest | should be "?OneItem=Test"
|
||||
}
|
||||
#TODO:: Figure out multi-item tests
|
||||
|
||||
it "should ignore CommonParameters" {
|
||||
Get-ZertoApiFilter -filtertable $commonParamTest | should be "?OneItem=Test"
|
||||
}
|
||||
|
||||
it "should process a filter table with more than one item" {
|
||||
$returnString = Get-ZertoApiFilter -filtertable $twoItemTest
|
||||
$returnString | Should -match "^\?"
|
||||
$returnString | Should -match "&"
|
||||
$returnString | Should -match "OneItem=Test"
|
||||
$returnString | Should -match "SecondItem=Yours"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,17 +1,96 @@
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$file = Get-ChildItem "$filePath\$fileName"
|
||||
. $file.FullName
|
||||
#Requires -Modules Pester
|
||||
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
|
||||
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
it "file should exist" {
|
||||
$file.FullName | should exist
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
$testCases = @(
|
||||
@{ParameterName = 'uri'; Type = 'String'; Mandatory = $true; TestName = 'URI' }
|
||||
@{ParameterName = 'method'; Type = 'String'; Mandatory = $false; TestName = 'Method' }
|
||||
@{ParameterName = 'body'; Type = 'String'; Mandatory = $false; TestName = 'Body' }
|
||||
@{ParameterName = 'contentType'; Type = 'String'; Mandatory = $false; TestName = 'contentType' }
|
||||
)
|
||||
|
||||
It "Parameter present and Type test for: <TestName> " -TestCases $testCases {
|
||||
param($parameterName, $type, $Mandatory)
|
||||
Get-Command $global:function | Should -HaveParameter $parameterName -Type $type
|
||||
if ($Mandatory) {
|
||||
Get-Command $global:function | Should -HaveParameter $parameterName -Mandatory
|
||||
} else {
|
||||
Get-Command $global:function | Should -HaveParameter $parameterName -Not -Mandatory
|
||||
}
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file.FullName -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
It "Method parameter default is 'GET'" {
|
||||
Get-Command $global:function | Should -HaveParameter Method -DefaultValue "GET"
|
||||
}
|
||||
|
||||
It "ContentType parameter default is 'application/json'" {
|
||||
Get-Command $global:function | Should -HaveParameter contentType -DefaultValue "application/json"
|
||||
}
|
||||
|
||||
$NotNullOrEmptyTests = @(
|
||||
@{ParameterName = 'uri'; TestName = 'Uri' }
|
||||
@{ParameterName = 'body'; TestName = 'Body' }
|
||||
@{ParameterName = 'contentType'; TestName = 'ContentType' }
|
||||
)
|
||||
|
||||
It "<TestName> parameter does not accecpt a null or empty value" -TestCases $NotNullOrEmptyTests {
|
||||
param($parameterName)
|
||||
$parameterInfo = ( Get-Command Invoke-ZARestRequest ).Parameters[$parameterName]
|
||||
$parameterInfo.Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
It "method parametert only accecpts 'GET' 'DELETE' 'PUT' 'POST' values" {
|
||||
$parameterInfo = ( Get-Command Invoke-ZARestRequest ).Parameters['method']
|
||||
$parameterInfo.Attributes.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1
|
||||
$validateSet = $parameterInfo.Attributes.Where{ $_ -is [ValidateSet] }
|
||||
$validateSet.ValidValues -contains 'GET' | Should -BeTrue
|
||||
$validateSet.ValidValues -contains 'PUT' | Should -BeTrue
|
||||
$validateSet.ValidValues -contains 'POST' | Should -BeTrue
|
||||
$validateSet.ValidValues -contains 'DELETE' | Should -BeTrue
|
||||
$validateSet.ValidValues.Count | Should -Be 4
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Function Unit Tests" {
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod {
|
||||
"Ran Command"
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
Set-Variable -Name zaHeaders -Scope Script -Value (@{ "Accept" = "application/json" })
|
||||
Set-Variable -Name zaLastActionTime -Scope Script -Value $(Get-Date).Ticks
|
||||
}
|
||||
|
||||
It "runs when called" {
|
||||
Invoke-ZARestRequest -uri "myuri" | Should Be "Ran Command"
|
||||
}
|
||||
|
||||
It "throws when the last action was over 60 minutes ago" {
|
||||
$script:zaLastActionTime = (Get-Date).AddMinutes(-61).Ticks
|
||||
{ Invoke-ZARestRequest -uri "myuri" } | Should Throw "Authorization Token has Expired."
|
||||
}
|
||||
|
||||
It "throws when the zaHeaders variable does not exits" {
|
||||
Remove-Variable -Name zaHeaders -Scope Script
|
||||
{ Invoke-ZARestRequest -uri "myuri" } | Should Throw "Zerto Analytics Connection does not Exist."
|
||||
}
|
||||
|
||||
It "throws when the zaLastActionTime variable does not exist" {
|
||||
Remove-Variable -Name zaLastActionTime -Scope Script
|
||||
{ Invoke-ZARestRequest -uri "myuri" } | Should Throw "Zerto Analytics Connection does not Exist."
|
||||
}
|
||||
|
||||
Assert-MockCalled -CommandName Invoke-RestMethod -ModuleName ZertoApiWrapper -Exactly 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,17 +1,93 @@
|
||||
$filePath = (Split-Path -Parent $MyInvocation.MyCommand.Path) -replace 'Tests', 'ZertoApiWrapper'
|
||||
$fileName = (Split-Path -Leaf $MyInvocation.MyCommand.Path ) -replace '.Tests.', '.'
|
||||
$file = Get-ChildItem "$filePath\$fileName"
|
||||
. $file.FullName
|
||||
#Requires -Modules Pester
|
||||
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
|
||||
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
it "file should exist" {
|
||||
$file.FullName | should exist
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod {
|
||||
"Ran Command"
|
||||
}
|
||||
|
||||
It "is valid Powershell (Has no script errors)" {
|
||||
$contents = Get-Content -Path $file.FullName -ErrorAction Stop
|
||||
$errors = $null
|
||||
$null = [System.Management.Automation.PSParser]::Tokenize($contents, [ref]$errors)
|
||||
$errors | Should -HaveCount 0
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
$thisCommand = Get-Command Invoke-ZertoRestRequest
|
||||
$ParameterNameTestCases = @(
|
||||
@{ParameterName = "uri"; Type = "String"; Mandatory = $true; DefaultValue = $null; TestName = "URI" }
|
||||
@{ParameterName = "method"; Type = "String"; Mandatory = $false; DefaultValue = 'GET'; TestName = "Method" }
|
||||
@{ParameterName = "apiVersion"; Type = "String"; Mandatory = $false; DefaultValue = 'v1'; TestName = "API Version" }
|
||||
@{ParameterName = "body"; Type = "String"; Mandatory = $false; DefaultValue = $null; TestName = "Body" }
|
||||
@{ParameterName = "contentType"; Type = "String"; Mandatory = $false; DefaultValue = 'application/json'; TestName = "Content Type" }
|
||||
@{ParameterName = "credential"; Type = "PSCredential"; Mandatory = $false; DefaultValue = $null; TestName = "Credential" }
|
||||
@{ParameterName = "returnHeaders"; Type = "Switch"; Mandatory = $false; DefaultValue = $null; TestName = "Return Headers" }
|
||||
)
|
||||
|
||||
It "<TestName> parameter has the right Type, Default Value, and Mandatory Setting" -TestCases $ParameterNameTestCases {
|
||||
param($ParameterName, $Type, $DefaultValue, $Mandatory)
|
||||
if ($Mandatory) {
|
||||
$thisCommand | Should -HaveParameter $ParameterName -Type $Type -Mandatory
|
||||
} else {
|
||||
$thisCommand | Should -HaveParameter $ParameterName -Type $Type
|
||||
$thisCommand | Should -HaveParameter $ParameterName -Not -Mandatory
|
||||
}
|
||||
if ($null -ne $DefaultValue) {
|
||||
$thisCommand | Should -HaveParameter $ParameterName -DefaultValue $DefaultValue
|
||||
}
|
||||
}
|
||||
|
||||
$ParameterValidationTestCases = @(
|
||||
@{ParameterName = "URI"; TestName = "URI" }
|
||||
@{ParameterName = "apiVersion"; TestName = "Api Version" }
|
||||
@{ParameterName = "body"; TestName = "Body" }
|
||||
@{ParameterName = "contentType"; TestName = "Content Type" }
|
||||
)
|
||||
|
||||
It "<TestName> parameter cannot be null or empty" -TestCases $ParameterValidationTestCases {
|
||||
param($ParameterName)
|
||||
$thisParameter = $thisCommand.Parameters[$ParameterName]
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should Be 1
|
||||
}
|
||||
|
||||
It "Method parameter can only be 'GET', 'POST', 'PUT', 'DELETE'" {
|
||||
$thisParameter = $thisCommand.Parameters['method']
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.Count | Should Be 1
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'GET' | Should -BeTrue
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'PUT' | Should -BeTrue
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'POST' | Should -BeTrue
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues -contains 'DELETE' | Should -BeTrue
|
||||
$thisParameter.Attributes.Where{ $_ -is [ValidateSet] }.validValues.Count | Should -Be 4
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Function Unit Tests" {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-RestMethod {
|
||||
"Ran Command"
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
Set-Variable -Name zvmHeaders -Scope Script -Value (@{ "Accept" = "application/json" })
|
||||
Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).Ticks
|
||||
Set-Variable -Name zvmServer -Scope Script -Value "192.168.1.100"
|
||||
Set-Variable -Name zvmPort -Scope Script -Value 9669
|
||||
}
|
||||
|
||||
It "runs when called" {
|
||||
Invoke-ZertoRestRequest -uri "MyUri" | Should -Be "Ran Command"
|
||||
}
|
||||
|
||||
It "throws an error when zvmLastAction was more than 30 minutes ago" {
|
||||
Set-Variable -Name zvmLastAction -Scope Script -Value $(Get-Date).AddMinutes(-31).Ticks
|
||||
{ Invoke-ZertoRestRequest -uri "MyUri" } | Should Throw "Authorization Token has Expired"
|
||||
}
|
||||
|
||||
It "throws an error when the zvmServer variable does not exist" {
|
||||
Remove-Variable -Name zvmServer -Scope Script
|
||||
{ Invoke-ZertoRestRequest -uri "MyUri" } | Should Throw "Zerto Connection does not Exist."
|
||||
}
|
||||
|
||||
Assert-MockCalled -CommandName Invoke-RestMethod -ModuleName ZertoApiWrapper -Exactly 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
[
|
||||
{
|
||||
"VMname": "ExchangeMailbox",
|
||||
"VMIdentifier": "vmid.12"
|
||||
},
|
||||
{
|
||||
"VMName": "ExchangeApplication",
|
||||
"VmIdentifier": "vmid.13"
|
||||
},
|
||||
{
|
||||
"VMName": "ExchangeWeb",
|
||||
"VmIdentifier": "vmid.14"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,76 +1,71 @@
|
||||
#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' {
|
||||
|
||||
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
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
BeforeAll {
|
||||
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
it "Has a mandatory string parameter for the target host" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetHost -Mandatory -Type String
|
||||
It "Has a mandatory string parameter for the target host" {
|
||||
Get-Command $global:function | Should -HaveParameter TargetHost -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Will not take a non-ip address as a 'TargetHost'" {
|
||||
{Add-ZertoPeerSite -targetHost 'MyZVMHost' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.266' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1' -targetPort '9081'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost $null -targetPort '9081'} | should -Throw
|
||||
It "Will not take a non-ip address as a 'TargetHost'" {
|
||||
{ Add-ZertoPeerSite -targetHost 'MyZVMHost' -targetPort '9081' } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.266' -targetPort '9081' } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1' -targetPort '9081' } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost $null -targetPort '9081' } | Should -Throw
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the target port with default value of 9081" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -Type Int32
|
||||
Get-Command $file.BaseName | Should -HaveParameter TargetPort -DefaultValue 9081
|
||||
It "Has a non-mandatory string parameter for the target port with default value of 9081" {
|
||||
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -Not -Mandatory
|
||||
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -Type Int32
|
||||
Get-Command Add-ZertoPeerSite | Should -HaveParameter TargetPort -DefaultValue 9081
|
||||
}
|
||||
|
||||
it "Will not take a non-int as a port" {
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string'} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $true} | should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $null} | should -Throw
|
||||
It "Will not take a non-int as a port" {
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 'string' } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $true } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort $null } | Should -Throw
|
||||
}
|
||||
|
||||
It "Will fail if the specified port is outside of the range 1024 - 65535" {
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 1023} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 65536} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 0} | Should -Throw
|
||||
{Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort -1} | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 1023 } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 65536 } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort 0 } | Should -Throw
|
||||
{ Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort -1 } | Should -Throw
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
It "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $global:function | Should -HaveParameter WhatIf
|
||||
Get-Command $global:function | Should -HaveParameter Confirm
|
||||
$script:ScriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$script:ScriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest {
|
||||
return "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
Context "Add-ZertoPeerSite::Functional Unit Tests" {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
return (Get-Content "$global:here\Mocks\TaskId.txt")
|
||||
}
|
||||
|
||||
it "Returns a string value" {
|
||||
It "Returns a string value" {
|
||||
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081'
|
||||
$results | should -Not -BeNullOrEmpty
|
||||
$results | should -BeOfType "String"
|
||||
$results | Should -BeExactly "9a49f42e-2bbd-4bf8-b571-77908a2e5e98.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
$results | Should -Not -BeNullOrEmpty
|
||||
$results | Should -BeOfType "String"
|
||||
$results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
It "Does not return a taskId if '-whatif' is used" {
|
||||
$results = Add-ZertoPeerSite -targetHost '192.168.1.100' -targetPort '9081' -WhatIf
|
||||
$results | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 1
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,66 +1,63 @@
|
||||
#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' {
|
||||
|
||||
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
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
BeforeAll {
|
||||
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
return "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
return (Get-Content "$global:here\Mocks\TaskId.txt")
|
||||
}
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg {
|
||||
return @{vpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"}
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg -ParameterFilter { $VpgName -eq "MyVpg" } {
|
||||
return (Get-Content "$global:here\Mocks\VPGInfo.json" -Raw | ConvertFrom-Json)
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "Has a parameter for the VpgName that is Mandatory" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Mandatory -Type String
|
||||
Context "$($global:function)::Parameter Unit Tests" {
|
||||
It "Has a parameter for the VpgName that is Mandatory" {
|
||||
Get-Command $global:function | Should -HaveParameter vpgName -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Has a parameter for the CheckpointName that is Mandatory" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter CheckpointName -Mandatory -Type String
|
||||
It "Has a parameter for the CheckpointName that is Mandatory" {
|
||||
Get-Command $global:function | Should -HaveParameter CheckpointName -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "Throws and error when an empty or null checkpointName is specified" {
|
||||
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw
|
||||
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName $null} | Should -Throw
|
||||
It "Throws and error when an empty or null checkpointName is specified" {
|
||||
{ Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "" } | Should -Throw
|
||||
{ Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName $null } | Should -Throw
|
||||
}
|
||||
|
||||
it "Throws an error when an empty or null vpgName is specified" {
|
||||
{Checkpoint-ZertoVpg -vpgName "" -checkpointName "MyCheckPoint"} | Should -Throw
|
||||
{Checkpoint-ZertoVpg -vpgName $null -checkpointName "MyCheckPoint"} | Should -Throw
|
||||
It "Throws an error when an empty or null vpgName is specified" {
|
||||
{ Checkpoint-ZertoVpg -vpgName "" -checkpointName "MyCheckPoint" } | Should -Throw
|
||||
{ Checkpoint-ZertoVpg -vpgName $null -checkpointName "MyCheckPoint" } | Should -Throw
|
||||
}
|
||||
|
||||
it "Does not support 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -Not -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -Not -HaveParameter Confirm
|
||||
$file | Should -Not -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -Not -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
It "Does not support 'SupportsShouldProcess'" {
|
||||
Get-Command $global:function | Should -Not -HaveParameter WhatIf
|
||||
Get-Command $global:function | Should -Not -HaveParameter Confirm
|
||||
$script:ScriptBlock | Should -not -match 'SupportsShouldProcess'
|
||||
$script:ScriptBlock | Should -not -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
Context "$($global:function)::Function Unit Tests" {
|
||||
|
||||
it "should return a not null or empty string" {
|
||||
It "should return a not null or empty string" {
|
||||
$results = Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "My Checkpoint Name"
|
||||
$results | should -not -BeNullOrEmpty
|
||||
$results | should -BeOfType "String"
|
||||
$results | should -BeExactly "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
$results | Should -not -BeNullOrEmpty
|
||||
$results | Should -BeOfType "String"
|
||||
$results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
|
||||
}
|
||||
It "does not return anything when a invalid VPG is defined" {
|
||||
$results = Checkpoint-ZertoVpg -vpgName "DoesNotExist" -checkpointName "My Checkpoint Name"
|
||||
$results | Should -Be "Cannot find VPG named DoesNotExist. Please check the name and try again."
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 2
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg -Exactly 1
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,19 +1,75 @@
|
||||
#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' {
|
||||
|
||||
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
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
BeforeAll {
|
||||
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
}
|
||||
|
||||
Context "$($global:function)::Parameter Unit Tests" {
|
||||
It "Has a parameter for the Required Credentials that is Mandatory" {
|
||||
Get-Command $global:function | Should -HaveParameter credential -Mandatory -Type PSCredential
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Context "$($global:function)::Function Unit Tests" {
|
||||
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Mock -CommandName Invoke-ZARestRequest {
|
||||
return (Get-Content "$global:here\Mocks\ZAToken.json"-Raw | ConvertFrom-Json)
|
||||
}
|
||||
|
||||
$password = 'NotARealPassword' | ConvertTo-SecureString -AsPlainText -Force
|
||||
$cred = New-Object pscredential('NotARealUser', $password)
|
||||
|
||||
$results = Connect-ZertoAnalytics -credential $cred
|
||||
|
||||
It "Creates a Script Level Hashtable Variable for the ZertoAnalytics Headers" {
|
||||
$script:zaHeaders | Should -BeOfType Hashtable
|
||||
}
|
||||
|
||||
It "the ZertoAnalytics Headers variable contains 2 items" {
|
||||
$script:zaHeaders.keys | Should -HaveCount 2
|
||||
}
|
||||
|
||||
It "the ZertoAnalytics Headers variable has an 'Accept' key" {
|
||||
$script:zaHeaders.keys | Should -Contain 'Accept'
|
||||
}
|
||||
|
||||
It "thh ZertoAnalytics headers variable 'Accept' key should be JSON" {
|
||||
$script:zaHeaders['Accept'] | Should -match 'application/json'
|
||||
}
|
||||
|
||||
It "the ZertoAnalytics Headers variable has an 'Authorization' key" {
|
||||
$script:zaHeaders.keys | Should -Contain 'Authorization'
|
||||
}
|
||||
|
||||
It "the ZertoAnalytics Headers variable 'Authorization' key should start with 'Bearer'" {
|
||||
$script:zaHeaders['Authorization'] | Should -Match '^Bearer '
|
||||
}
|
||||
|
||||
It "Creates a Script Level Variable for the LastActionTime" {
|
||||
$script:zaLastActionTime | Should -BeOfType Long
|
||||
}
|
||||
|
||||
It "LastActionTime Variable should be in the past" {
|
||||
$script:zaLastActionTime | Should -BeLessThan (Get-Date).Ticks
|
||||
}
|
||||
|
||||
It "Returns Header Information" {
|
||||
$results | Should -not -BeNullOrEmpty
|
||||
$results['Authorization'] | Should -MatchExactly 'Bearer N074r34l70k3n'
|
||||
$results['Accept'] | Should -Match 'application/json'
|
||||
}
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZARestRequest -Exactly 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,128 +1,94 @@
|
||||
#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
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
$Server = "192.168.1.100"
|
||||
$zertoPort = "7669"
|
||||
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
|
||||
|
||||
Describe $file.BaseName -Tag Unit {
|
||||
|
||||
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
|
||||
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
|
||||
BeforeAll {
|
||||
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
Context "$($global:function)::Parameter Unit Tests" {
|
||||
|
||||
it "server vairable has a mandatory String parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoserver -Mandatory -Type String
|
||||
It "server vairable has a mandatory String parameter" {
|
||||
Get-Command $global:function | Should -HaveParameter zertoserver -Mandatory -Type String
|
||||
}
|
||||
|
||||
it "server variable does not accecpt an empty or null input" {
|
||||
{Connect-ZertoServer -zertoServer $null -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer "" -credential $credential} | Should -Throw
|
||||
It "server variable does not accecpt an empty or null input" {
|
||||
{ Connect-ZertoServer -zertoServer $null -credential $credential } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer "" -credential $credential } | Should -Throw
|
||||
}
|
||||
|
||||
it "port variable has a non-mandatory String parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -Type String
|
||||
Get-Command $file.BaseName | Should -HaveParameter zertoPort -DefaultValue "9669"
|
||||
It "port variable has a non-mandatory String parameter" {
|
||||
Get-Command $global:function | Should -HaveParameter zertoPort -Not -Mandatory
|
||||
Get-Command $global:function | Should -HaveParameter zertoPort -Type String
|
||||
Get-Command $global:function | Should -HaveParameter zertoPort -DefaultValue "9669"
|
||||
}
|
||||
|
||||
it "port variable does not accecpt an empty or null input" {
|
||||
{Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "" -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort $null -credential $credential} | Should -Throw
|
||||
It "port variable does not accecpt an empty or null input" {
|
||||
{ Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort "" -credential $credential } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer "192.168.1.100" -zertoPort $null -credential $credential } | Should -Throw
|
||||
}
|
||||
|
||||
it "port variable should fall between 1024 and 65535" {
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort 0 -credential $credential} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer $Server -zertoPort -1 -credential $credential} | Should -Throw
|
||||
It "port variable should fall between 1024 and 65535" {
|
||||
{ Connect-ZertoServer -zertoServer $Server -zertoPort 1023 -credential $credential } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer $Server -zertoPort 65536 -credential $credential } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer $Server -zertoPort 0 -credential $credential } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer $Server -zertoPort -1 -credential $credential } | Should -Throw
|
||||
}
|
||||
|
||||
it "has a mandatory PSCredential parameter for the credential vairable" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter credential -Mandatory -Type PSCredential
|
||||
It "has a mandatory PSCredential parameter for the credential vairable" {
|
||||
Get-Command $global:function | Should -HaveParameter credential -Mandatory -Type PSCredential
|
||||
}
|
||||
|
||||
it "should require a PSCredentialObject for the credentials" {
|
||||
{Connect-ZertoServer -zertoServer -credential "MyUsername"} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer -credential 1234} | Should -Throw
|
||||
{Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString'})} | Should -Throw
|
||||
It "should require a PSCredentialObject for the credentials" {
|
||||
{ Connect-ZertoServer -zertoServer -credential "MyUsername" } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer -credential 1234 } | Should -Throw
|
||||
{ Connect-ZertoServer -zertoServer -credential $(@{Username = "zerto\build"; Password = 'SecureString' }) } | Should -Throw
|
||||
}
|
||||
}
|
||||
|
||||
InModuleScope ZertoApiWrapper {
|
||||
Context "$($file.BaseName)::InModuleScope Function Unit Tests" {
|
||||
|
||||
$server = '192.168.1.100'
|
||||
$userName = "zerto\build"
|
||||
$password = ConvertTo-SecureString -String "ZertoBuild" -AsPlainText -Force
|
||||
$credential = New-Object -TypeName System.Management.Automation.PSCredential($userName, $password)
|
||||
|
||||
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
$xZertoSession = @("7ecf544d-e7ed-4108-86f3-fb355c51cdfa")
|
||||
$Headers = @{'x-zerto-session' = $xZertoSession}
|
||||
$results = @{'Headers' = $Headers}
|
||||
# Attempted to Mock this per the Mock Below and it blew up. Auth Headers Returns a Dictionary
|
||||
# and does not index the same way when imported from a JSON file. Need addtional investigation.
|
||||
$xZertoSession = @("e34da0b0-4bc2-4cda-b316-0384e35bdca5")
|
||||
$Headers = @{'x-zerto-session' = $xZertoSession }
|
||||
$results = @{'Headers' = $Headers }
|
||||
return $results
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite {
|
||||
$results = @{
|
||||
BandwidthThrottlingInMBs = -1
|
||||
ContactEmail = "vSphere-Site01@zerto.com"
|
||||
ContactName = "vSphere-Site01@zerto.com"
|
||||
ContactPhone = "066-6666666"
|
||||
IpAddress = "192.168.200.1"
|
||||
IsReplicationToSelfEnabled = $True
|
||||
Link = @{
|
||||
href = "https://192.168.24.1:7669/v1/localsite"
|
||||
identifier = "928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
rel = $null
|
||||
type = "LocalSiteApi"
|
||||
}
|
||||
Location = "vSphere-Site01"
|
||||
SiteName = "vSphere-Site01 at Zerto"
|
||||
SiteType = "VCenter"
|
||||
UtcOffsetInMinutes = -240
|
||||
Version = "7.0.0"
|
||||
SiteIdentifier = "928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
}
|
||||
return $results
|
||||
return (Get-Content -Path "$global:here\Mocks\LocalSiteInfo.json" -Raw | ConvertFrom-Json)
|
||||
}
|
||||
|
||||
Context "$($global:function)::InModuleScope Function Unit Tests" {
|
||||
|
||||
BeforeAll {
|
||||
$server = '192.168.1.100'
|
||||
$password = ConvertTo-SecureString -String "NotARealPassword" -AsPlainText -Force
|
||||
$credential = New-Object pscredential('NotARealUser', $password)
|
||||
$now = $(Get-Date).ticks
|
||||
Connect-ZertoServer -zertoServer $server -credential $credential
|
||||
}
|
||||
|
||||
it "Module Scope zvmServer variable tests" {
|
||||
It "Module Scope zvmServer variable tests" {
|
||||
$script:zvmServer | Should -Not -BeNullOrEmpty
|
||||
$script:zvmServer | Should -Be $server
|
||||
}
|
||||
|
||||
it "Module Scope zvmPort variable tests" {
|
||||
It "Module Scope zvmPort variable tests" {
|
||||
$script:zvmPort | Should -Not -BeNullOrEmpty
|
||||
$script:zvmPort | Should -Be '9669'
|
||||
}
|
||||
|
||||
it "Module Scope zvmLastAction variable tests" {
|
||||
It "Module Scope zvmLastAction variable tests" {
|
||||
$script:zvmLastAction | Should -Not -BeNullOrEmpty
|
||||
$script:zvmLastAction | Should -BeGreaterOrEqual $now
|
||||
}
|
||||
|
||||
it "Module Scope zvmHeaders variable tests" {
|
||||
It "Module Scope zvmHeaders variable tests" {
|
||||
$script:zvmHeaders | Should -Not -BeNullOrEmpty
|
||||
$script:zvmHeaders | Should -BeOfType Hashtable
|
||||
$script:zvmHeaders | Should -BeOfType PSCustomObject
|
||||
$script:zvmHeaders.keys.count | Should -BeExactly 2
|
||||
$script:zvmHeaders.ContainsKey('x-zerto-session') | Should -BeTrue
|
||||
$script:zvmHeaders.ContainsKey('Accept') | Should -BeTrue
|
||||
@@ -130,74 +96,48 @@ Describe $file.BaseName -Tag Unit {
|
||||
$script:zvmHeaders['Accept'] | Should -BeOfType String
|
||||
}
|
||||
|
||||
it "Module Scope zvmLocalInfo variable tests" {
|
||||
It "Module Scope zvmLocalInfo variable tests" {
|
||||
$script:zvmLocalInfo | Should -Not -BeNullOrEmpty
|
||||
$script:zvmLocalInfo | Should -BeOfType Hashtable
|
||||
$script:zvmLocalInfo['SiteIdentifier'] | Should -BeOfType String
|
||||
$script:zvmLocalInfo.ContainsKey('SiteIdentifier') | Should -BeTrue
|
||||
$script:zvmLocalInfo['SiteIdentifier'] | Should -BeOfType String
|
||||
$script:zvmLocalInfo | Should -BeOfType PSCustomObject
|
||||
$script:zvmLocalInfo.SiteIdentifier | Should -BeOfType String
|
||||
}
|
||||
|
||||
$headers = Connect-ZertoServer -zertoServer $Server -credential $credential -returnHeaders
|
||||
it "returns a Hashtable with 2 keys" {
|
||||
It "returns a Hashtable with 2 keys" {
|
||||
$headers | Should -BeOfType Hashtable
|
||||
$headers.keys.count | should be 2
|
||||
$headers.keys.count | Should be 2
|
||||
}
|
||||
|
||||
it "return value has a key called 'x-zerto-session'" {
|
||||
$headers.ContainsKey('x-zerto-session') | should be $true
|
||||
It "return value has a key called 'x-zerto-session'" {
|
||||
$headers.ContainsKey('x-zerto-session') | Should be $true
|
||||
}
|
||||
|
||||
it "return key 'x-zerto-session' value should be a string" {
|
||||
$headers['x-zerto-session'] | should -BeOfType "String"
|
||||
$headers['x-zerto-session'] | Should -BeExactly "7ecf544d-e7ed-4108-86f3-fb355c51cdfa"
|
||||
It "return key 'x-zerto-session' value should be a string" {
|
||||
$headers['x-zerto-session'] | Should -BeOfType "String"
|
||||
$headers['x-zerto-session'] | Should -BeExactly "e34da0b0-4bc2-4cda-b316-0384e35bdca5"
|
||||
}
|
||||
|
||||
it "return value has a key called 'accept'" {
|
||||
$headers.ContainsKey('accept') | should be $true
|
||||
It "return value has a key called 'accept'" {
|
||||
$headers.ContainsKey('accept') | Should be $true
|
||||
}
|
||||
|
||||
it "return key 'accept' value should be 'application/json'" {
|
||||
$headers['accept'] | should be 'application/json'
|
||||
It "return key 'accept' value should be 'application/json'" {
|
||||
$headers['accept'] | Should be 'application/json'
|
||||
}
|
||||
|
||||
it "should not require a port to be specified" {
|
||||
It "should not require a port to be specified" {
|
||||
Connect-ZertoServer -zertoServer $Server -credential $credential
|
||||
}
|
||||
|
||||
it "returns null when -ReturnHeaders is not used" {
|
||||
It "returns null when -ReturnHeaders is not used" {
|
||||
Connect-ZertoServer -zertoServer $Server -credential $credential | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 4
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite -Exactly 4
|
||||
}
|
||||
}
|
||||
}
|
||||
<#
|
||||
Describe "Connect-ZertoServer" -Tag Integration {
|
||||
it "file should exist" {
|
||||
"$filePath\$fileName" | should exist
|
||||
}
|
||||
it "has a function called Connect-ZertoServer" {
|
||||
get-command Connect-ZertoServer | should be $true
|
||||
}
|
||||
$headers = Connect-ZertoServer -zertoServer $Server -zertoPort $zertoPort -credential $credential -returnHeaders
|
||||
it "returns a Hashtable with 2 keys" {
|
||||
$headers.keys.count | should be 2
|
||||
}
|
||||
it "return value has a key called 'x-zerto-session'" {
|
||||
$headers.ContainsKey('x-zerto-session') | should be $true
|
||||
}
|
||||
it "return key 'x-zerto-session' value should be a string" {
|
||||
$headers['x-zerto-session'].gettype().name | should be "String"
|
||||
}
|
||||
it "return value has a key called 'accept'" {
|
||||
$headers.ContainsKey('accept') | should be $true
|
||||
}
|
||||
it "return key 'accept' value should be 'application/json'" {
|
||||
$headers['accept'] | should be 'application/json'
|
||||
}
|
||||
Disconnect-ZertoServer
|
||||
}
|
||||
#>
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
#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' {
|
||||
|
||||
Context "$($global:function)::Parameter Unit Tests" {
|
||||
It "Does not take any parameters" {
|
||||
(Get-Command disconnect-zertoserver).parameters.count | Should -BeExactly 11
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($global:function)::Function Unit Tests" {
|
||||
InModuleScope -ModuleName ZertoApiWrapper {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
|
||||
$null
|
||||
}
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Remove-Variable {
|
||||
|
||||
# Attempted to Mock this per the Mock Below and it blew up. Auth Headers Returns a Dictionary
|
||||
# and does not index the same way when imported from a JSON file. Need addtional investigation.
|
||||
$xZertoSession = @("e34da0b0-4bc2-4cda-b316-0384e35bdca5")
|
||||
$Headers = @{'x-zerto-session' = $xZertoSession }
|
||||
$results = @{'Headers' = $Headers }
|
||||
return $results
|
||||
}
|
||||
|
||||
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
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoLocalSite {
|
||||
return (Get-Content -Path "$global:here\Mocks\LocalSiteInfo.json" -Raw | ConvertFrom-Json)
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "Does not take any parameters" {
|
||||
(get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11
|
||||
}
|
||||
BeforeAll {
|
||||
Connect-ZertoServer
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
it "Does not return anything" {
|
||||
It "Does not return anything" {
|
||||
Disconnect-ZertoServer | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,187 +1,97 @@
|
||||
#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' {
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper Invoke-ZertoRestRequest {
|
||||
return "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
Get-Content $global:here\Mocks\TaskId.txt
|
||||
}
|
||||
|
||||
Mock -ModuleName ZertoApiWrapper Get-ZertoVra {
|
||||
$vraInformation = @{
|
||||
DatastoreClusterIdentifier = $null
|
||||
DatastoreClusterName = $null
|
||||
DatastoreIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.Prod_Datastore"
|
||||
DatastoreName = "Prod_Datastore"
|
||||
HostIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.znest82esxus-1"
|
||||
HostVersion = 6.5
|
||||
IpAddress = 192.168.1.100
|
||||
Link = @{
|
||||
href = "https://192.168.1.200:7669/v1/vras/2609816293328110468"
|
||||
identifier = "269816293328110468"
|
||||
rel = $null
|
||||
type = "VraApi"
|
||||
}
|
||||
MemoryInGB = 3
|
||||
NetworkIdentifier = "840f99fb-4689-2f8b-ea10-2a47a5bb00cc.network-1"
|
||||
NetworkName = "Test Network"
|
||||
Progress = 0
|
||||
ProtectedCounters = @{
|
||||
Vms = 0
|
||||
Volumes = 0
|
||||
Vpgs = 0
|
||||
}
|
||||
RecoveryCounters = @{
|
||||
Vms = 0
|
||||
Volumes = 0
|
||||
Vpgs = 0
|
||||
}
|
||||
SelfProtectedVpgs = 0
|
||||
Status = 0
|
||||
VraAlerts = @{
|
||||
VraAlertStatus = 0
|
||||
}
|
||||
VraGroup = "default_group"
|
||||
VraIdentifier = 269816293328110468
|
||||
VraIdentifierStr = "269816293328110468"
|
||||
VraName = "VRA-znest82esxus-1"
|
||||
VraNetworkDataApi = @{
|
||||
DefaultGateway = "192.168.1.1"
|
||||
SubnetMask = "255.255.255.0"
|
||||
VraIpAddress = "192.168.1.100"
|
||||
VraIpConfigurationTypeApi = "Dhcp"
|
||||
}
|
||||
VraVersion = 7.0
|
||||
}
|
||||
return $vraInformation
|
||||
Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -eq "MyVraIdentifier" } {
|
||||
Get-Content $global:here\Mocks\GetSingleVra.json -Raw | ConvertFrom-Json
|
||||
}
|
||||
|
||||
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
|
||||
Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -eq "DoesNotExist" } {
|
||||
$null
|
||||
}
|
||||
|
||||
Context "$($File.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "has a mandatory String variable for the vraIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIdentifier -Mandatory -Type String
|
||||
{Edit-ZertoVra}
|
||||
Mock -ModuleName ZertoApiWrapper Get-ZertoVra -ParameterFilter { $vraIdentifier -eq "DhcpVraIdentifier" } {
|
||||
Get-Content $global:here\Mocks\GetDhcpVra.json -Raw | ConvertFrom-Json
|
||||
}
|
||||
|
||||
It "has a non-mandatory String variable for the Bandwidth Group" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter groupName -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter groupName -Type String
|
||||
Context "$($global:function)::Parameter Unit Tests" {
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vraIdentifier'; Type = 'String'; Mandatory = $true }
|
||||
@{ParameterName = 'groupName'; Type = 'String'; Mandatory = $false }
|
||||
@{ParameterName = 'vraIpAddress'; Type = 'String'; Mandatory = $false }
|
||||
@{ParameterName = 'defaultGateway'; Type = 'String'; Mandatory = $false }
|
||||
@{ParameterName = 'subnetMask'; Type = 'String'; Mandatory = $false }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
it "has a non-mandatory String variable for the staticIp Address" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String
|
||||
$StringTestCases = @(
|
||||
@{ ParameterName = 'vraIdentifier' }
|
||||
@{ ParameterName = 'groupName' }
|
||||
)
|
||||
|
||||
it "<ParameterName> validates against null or empty values" -TestCases $StringTestCases {
|
||||
param($ParameterName)
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory String variable for the default gateway" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String
|
||||
}
|
||||
$IpAddrTestCases = @(
|
||||
@{ParameterName = 'vraIpAddress' }
|
||||
@{ParameterName = 'defaultGateway' }
|
||||
@{ParameterName = 'subnetMask' }
|
||||
)
|
||||
|
||||
it "has a non-mandatory String variable for the subnetmask" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String
|
||||
}
|
||||
|
||||
it "supports WhatIf" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf -Not -Mandatory
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{vraIpAddress = "192.168.1.256"}, `
|
||||
@{vraIpAddress = "192.168.1"}, `
|
||||
@{vraIpAddress = "String"}, `
|
||||
@{vraIpAddress = 192.168.1}, `
|
||||
@{vraIpAddress = 192.168.1.246}, `
|
||||
@{vraIpAddress = 32}, `
|
||||
@{vraIpAddress = ""}, `
|
||||
@{vraIpAddress = $null}
|
||||
It "IpAddress field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -vraIpaddress $vraIpAddress} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{subnetMask = "192.168.1.256"}, `
|
||||
@{subnetMask = "192.168.1"}, `
|
||||
@{subnetMask = "String"}, `
|
||||
@{subnetMask = 192.168.1}, `
|
||||
@{subnetMask = 192.168.1.246}, `
|
||||
@{subnetMask = 32}, `
|
||||
@{subnetMask = ""}, `
|
||||
@{subnetMask = $null}
|
||||
It "subnetMask field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -subnetMask $subnetMask} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{defaultGateway = "192.168.1.256"}, `
|
||||
@{defaultGateway = "192.168.1"}, `
|
||||
@{defaultGateway = "String"}, `
|
||||
@{defaultGateway = 192.168.1}, `
|
||||
@{defaultGateway = 192.168.1.246}, `
|
||||
@{defaultGateway = 32}, `
|
||||
@{defaultGateway = ""}, `
|
||||
@{defaultGateway = $null}
|
||||
It "defaultGateway field require valid IP addresses as a String" -TestCases $cases {
|
||||
param ( $vraIpAddress )
|
||||
{Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -defaultGateway $defaultGateway} | Should -Throw
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{vraIdentifier = ""; paramName = "vraIdentifier"; paramValue = ""}, `
|
||||
@{vraIdentifier = $null; paramName = "vraIdentifier"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "groupName"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "vraIpAddress"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "subnetMask"; paramValue = $null}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = ""}, `
|
||||
@{vraIdentifier = "MyVraIdentifier"; paramName = "defaultGateway"; paramValue = $null}
|
||||
|
||||
It "<paramName> does not take empty or null" -TestCases $cases {
|
||||
param($vraIdentifier, $paramValue, $paramName )
|
||||
if ([String]::IsNullOrEmpty($vraIdentifier)) {
|
||||
{Edit-ZertoVra -vraIdentifier $vraIdentifier} | Should -Throw
|
||||
} else {
|
||||
{Edit-ZertoVra -vraIdentifier $vraIdentifier -$paramName $paramValue} | should -Throw
|
||||
}
|
||||
it "<ParameterName> validates string for a valid IP Address" -TestCases $IpAddrTestCases {
|
||||
param($ParameterName)
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1
|
||||
$attrs.Where{ $_ -is [ValidateScript] }.ScriptBlock | Should -Match '^\$_ \-match \[IPAddress\]\$_'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($File.BaseName)::Function Unit Tests" {
|
||||
Context "$($global:function)::Function Unit Tests" {
|
||||
|
||||
It "Returns a string" {
|
||||
It "Returns a task id string" {
|
||||
$results = Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -groupName "MyGroup"
|
||||
$results | should not benullorempty
|
||||
$results | should -BeOfType "String"
|
||||
$results | Should -BeExactly "8dcfdc8e-e5d2-4ba4-9885-f9eb57d92b14.928a122b-1763-4664-ad37-cc00bb883f2f"
|
||||
$results | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
|
||||
}
|
||||
|
||||
It "Throws an error when the VPG does not exist" {
|
||||
{ Edit-ZertoVra -vraIdentifier "DoesNotExist" -groupName "MyNewGroup" } | Should Throw "VRA with Identifier:"
|
||||
}
|
||||
|
||||
It "Runs when passed static IP information" {
|
||||
Edit-ZertoVra -vraIdentifier "MyVraIdentifier" -vraIpAddress "192.168.1.250" -defaultGateway "192.168.1.254" -subnetMask "255.255.255.0"
|
||||
}
|
||||
|
||||
It "Processes a VRA with a DHCP address" {
|
||||
Edit-ZertoVra -vraIdentifier "DhcpVraIdentifier" -groupName "MyNewGroup" | Should -BeExactly "7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a"
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
Get-Command $global:function | Should -HaveParameter WhatIf
|
||||
Get-Command $global:function | Should -HaveParameter Confirm
|
||||
(Get-Command $global:function).ScriptBlock | Should -Match 'SupportsShouldProcess'
|
||||
(Get-Command $global:function).ScriptBlock | Should -Match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
}
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest -Exactly 3
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVra -Exactly 4
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,42 +1,32 @@
|
||||
#Requires -Modules Pester
|
||||
#Region - Test Setup
|
||||
$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
|
||||
#EndRegion
|
||||
$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" {
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'OutputFile'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
It "has a mantatory string parameter for the output file" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter OutputFile -Type String -Mandatory
|
||||
it "<ParameterName> has <Validation> validation set" -TestCases $ParameterTestCases {
|
||||
param($ParameterName)
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
}
|
||||
|
||||
It "has a non-mandatory string array parameter for vpgName(s) to export" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type String[]
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Not -Mandatory
|
||||
}
|
||||
Context "$global:function::Function Unit Tests" {
|
||||
|
||||
It "Output File does not take null or empty string" {
|
||||
{ Export-ZertoVpg -outputFile "" } | Should -Throw
|
||||
{ Export-ZertoVpg -outputFile $null } | Should -Throw
|
||||
}
|
||||
|
||||
It "Vpg Name parameter does not take null or empty string" {
|
||||
{ Export-ZertoVpg -outputFile ".\ExportedInfo.csv" -vpgName = "" } | Should -Throw
|
||||
{ Export-ZertoVpg -outputFile ".\ExportedInfo.csv" -vpgName = $null } | Should -Throw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,53 +1,39 @@
|
||||
#Requires -Modules Pester
|
||||
#Region - Test Setup
|
||||
$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
|
||||
#EndRegion
|
||||
$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" {
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'OutputPath'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'allVpgs'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type, with correct validation" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
it "has a mantatory string parameter for the output path" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter outputPath -Type String -Mandatory
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory string array parameter for vpgName(s) to export" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgName -Type String[] -Mandatory
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
it "has a non-mandatory switch parameter to export all vpgs" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter allVpgs -Type Switch -Mandatory
|
||||
}
|
||||
|
||||
it "No defined vpgName or AllVpg switch should throw an error" {
|
||||
{Export-ZertoVpg -outputPath "."} | Should -Throw
|
||||
}
|
||||
|
||||
it "Output path does not take null or empty string" {
|
||||
{Export-ZertoVpg -outputPath "" -allVpgs} | Should -Throw
|
||||
{Export-ZertoVpg -outputPath $null -allVpgs} | Should -Throw
|
||||
}
|
||||
|
||||
it "Vpg Name parameter does not take null or empty string" {
|
||||
{Export-ZertoVpg -outputPath "." -vpgName = ""} | Should -Throw
|
||||
{Export-ZertoVpg -outputPath "." -vpgName = $null} | Should -Throw
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
Context "$($global:function)::Function Unit Tests" {
|
||||
Mock -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg {
|
||||
$returnObj = @{
|
||||
VpgName = "HRIS"
|
||||
@@ -247,3 +233,6 @@ Describe $file.BaseName -Tag 'Unit' {
|
||||
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpgSetting
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name function -Scope Global
|
||||
Remove-Variable -Name here -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'limitTo'; Type = 'int'; Mandatory = $false; Validation = 'Range' }
|
||||
@{ParameterName = 'alertIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "LimitTo Parameter should have a Min value of 1" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 1
|
||||
}
|
||||
|
||||
It "LimitTo Parameter should have a Max value of 1000000" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 1000000
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'datastoreIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'clusterIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,77 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
it "$global:function should have exactly 16 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 16
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'limitTo'; Type = 'int'; Mandatory = $false; Validation = 'Range' }
|
||||
@{ParameterName = 'category'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Set' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "LimitTo Parameter should have a Min value of 1" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 1
|
||||
}
|
||||
|
||||
It "LimitTo Parameter should have a Max value of 1000000" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 1000000
|
||||
}
|
||||
|
||||
It "Category parameter should only have 2 options" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should Be 2
|
||||
}
|
||||
|
||||
It "Category parameter should take 'events'" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events'
|
||||
}
|
||||
|
||||
It "Category parameter should take 'alertsHistory'" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alertsHistory'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,59 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 11 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 11
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
it "$global:function should have exactly 12 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
it "$global:function has a non-mandatory string parameter for the zOrgIdentifier" {
|
||||
Get-Command $global:function | Should -HaveParameter zOrgIdentifier -Type String
|
||||
Get-Command $global:function | Should -HaveParameter zOrgIdentifier -not -Mandatory
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,60 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 17 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 17
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,60 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 17 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 17
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,51 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 16 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 16
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,51 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 16 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 16
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'protectedSiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'recoverySiteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 15 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 15 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,58 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 15 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'Interval'; Type = 'Int32'; Mandatory = $false; Validation = 'Range' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 60" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 60
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 2678400" {
|
||||
(Get-Command $global:function).Parameters['Interval'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 2678400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 12 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
It "zOrgIdentifier Parameter should be present and of 'String' Type" {
|
||||
Get-Command $global:function | Should -HaveParameter zOrgIdentifier -Type String -Mandatory:$false
|
||||
}
|
||||
|
||||
It "zOrgIdentifier has the NotNullOrEmpty Validator" {
|
||||
(Get-Command $global:function).Parameters['zOrgIdentifier'].Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should Be 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,42 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 12 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,57 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 14 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'limitTo'; Type = 'Int'; Mandatory = $false; Validation = 'Range' }
|
||||
@{ParameterName = 'taskIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Min value of 1" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should Be 1
|
||||
}
|
||||
|
||||
It "Interval Parameter should have a Max value of 1000000" {
|
||||
(Get-Command $global:function).Parameters['limitTo'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should Be 1000000
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,45 @@
|
||||
#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" {
|
||||
It "$global:function should have exactly 15 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'clusterIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'datastoreIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,43 @@
|
||||
#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" {
|
||||
It "$global:function should have exactly 13 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 13
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 11 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 11
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,84 +1,51 @@
|
||||
#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" {
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'alertId'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'entities'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'helpIdentifiers'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'levels'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'level'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'helpIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'isDismissed'; Type = 'bool'; Mandatory = $false; Validation = $null }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "Has a mandatory string parameter for the Alert identifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter alertId
|
||||
Get-Command $file.BaseName | Should -HaveParameter alertId -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter alertId -Type String[]
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "Has a non-mandatory switch parameter for the entities" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter entities
|
||||
Get-Command $file.BaseName | Should -HaveParameter entities -Type switch
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it "Has a non-mandatory switch parameter for the helpIdentifiers" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter helpIdentifiers
|
||||
Get-Command $file.BaseName | Should -HaveParameter helpIdentifiers -Type switch
|
||||
}
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
it "Has a non-mandatory switch parameter for the levels" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter levels
|
||||
Get-Command $file.BaseName | Should -HaveParameter levels -Type switch
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the startDate" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter startDate
|
||||
Get-Command $file.BaseName | Should -HaveParameter startDate -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the endDate" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter endDate
|
||||
Get-Command $file.BaseName | Should -HaveParameter endDate -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the vpgIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter vpgIdentifier -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the siteIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter siteIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter siteIdentifier -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the zorgIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter zorgIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter zorgIdentifier -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the level" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter level
|
||||
Get-Command $file.BaseName | Should -HaveParameter level -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory string parameter for the helpIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter helpIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter helpIdentifier -Type string
|
||||
}
|
||||
|
||||
it "Has a non-mandatory bool parameter for the isDismissed" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter isDismissed
|
||||
Get-Command $file.BaseName | Should -HaveParameter isDismissed -Type bool
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,24 +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" {
|
||||
|
||||
It "has a non-mandatory string parameter for the datacenterIdentifier" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreIdentifier -Type String[]
|
||||
Get-Command $global:function | Should -HaveParameter datastoreIdentifier
|
||||
Get-Command $global:function | Should -HaveParameter datastoreIdentifier -Type String[]
|
||||
}
|
||||
|
||||
It "datastoreIdentifier parameter does not take null or empty values" {
|
||||
(Get-Command $global:function).Parameters['datastoreIdentifier'].Attributes.Where{ $_ -is [ValidateNotNullOrEmpty] }.count | Should Be 1
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,120 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 28 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 28
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'startDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'endDate'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpg'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'vpgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'eventType'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'siteName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'siteIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'zOrgIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'entityType'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'userName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'category'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'eventCategory'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'alertIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'eventId'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'categories'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'entities'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'types'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'Set' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "entityType parameter only accecpts 4 different values" {
|
||||
(Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should be 4
|
||||
}
|
||||
|
||||
It "entityType parameter accecpts 'VPG' as a Value" {
|
||||
(Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'VPG'
|
||||
}
|
||||
|
||||
It "entityType parameter accecpts 'VRA' as a Value" {
|
||||
(Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'VRA'
|
||||
}
|
||||
|
||||
It "entityType parameter accecpts 'Unknown' as a Value" {
|
||||
(Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Unknown'
|
||||
}
|
||||
|
||||
It "entityType parameter accecpts 'Site' as a Value" {
|
||||
(Get-Command $global:function).Parameters['entityType'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Site'
|
||||
}
|
||||
|
||||
It "category parameter only accecpts 3 different values" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should be 3
|
||||
}
|
||||
|
||||
It "category parameter accecpts 'All' as a Value" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'All'
|
||||
}
|
||||
|
||||
It "category parameter accecpts 'events' as a Value" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events'
|
||||
}
|
||||
|
||||
It "category parameter accecpts 'alerts' as a Value" {
|
||||
(Get-Command $global:function).Parameters['category'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alerts'
|
||||
}
|
||||
|
||||
It "eventCategory parameter only accecpts 3 different values" {
|
||||
(Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues.Count | Should be 3
|
||||
}
|
||||
|
||||
It "eventCategory parameter accecpts 'All' as a Value" {
|
||||
(Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'All'
|
||||
}
|
||||
|
||||
It "eventCategory parameter accecpts 'events' as a Value" {
|
||||
(Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'events'
|
||||
}
|
||||
|
||||
It "eventCategory parameter accecpts 'alerts' as a Value" {
|
||||
(Get-Command $global:function).Parameters['eventCategory'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'alerts'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 11 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 11
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
#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" {
|
||||
It "$global:function should have exactly 12 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
it "Has a non-mandatory switch parameter for the pairing Statuses" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter pairingstatuses
|
||||
Get-Command $file.BaseName | Should -HaveParameter pairingstatuses -Type switch
|
||||
It "Has a non-mandatory switch parameter for the pairing Statuses" {
|
||||
Get-Command $global:function | Should -HaveParameter pairingstatuses
|
||||
Get-Command $global:function | Should -HaveParameter pairingstatuses -Type switch
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,53 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
It "$global:function should have exactly 18 parameters defined" {
|
||||
(Get-Command $global:function).Parameters.Count | Should -Be 18
|
||||
}
|
||||
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'pairingStatuses'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'siteIdentifier'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'peerName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'paringStatus'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'location'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'hostName'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'port'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
default {
|
||||
$true | Should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,39 +1,30 @@
|
||||
#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" {
|
||||
it "$global:function should have exactly 11 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "Has a mandatory string array parameter for the settings file to import" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter InputFile
|
||||
Get-Command $file.BaseName | Should -HaveParameter InputFile -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter InputFile -Type String
|
||||
Get-Command $global:function | Should -HaveParameter InputFile
|
||||
Get-Command $global:function | Should -HaveParameter InputFile -Mandatory
|
||||
Get-Command $global:function | Should -HaveParameter InputFile -Type String
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the settings file" {
|
||||
{ Import-ZertoVpg -InputFile $null } | Should -Throw
|
||||
{ Import-ZertoVpg -InputFile "" } | Should -Throw
|
||||
{ Import-ZertoVpg -InputFile @() } | Should -Throw
|
||||
$attrs = (Get-Command $global:function).Parameters['InputFile'].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,39 +1,30 @@
|
||||
#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" {
|
||||
it "$global:function should have exactly 12 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
It "Has a mandatory string array parameter for the settings file to import" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter settingsFile -Type String[]
|
||||
Get-Command $global:function | Should -HaveParameter settingsFile
|
||||
Get-Command $global:function | Should -HaveParameter settingsFile -Mandatory
|
||||
Get-Command $global:function | Should -HaveParameter settingsFile -Type String[]
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the settings file" {
|
||||
{Import-ZertoVpg -settingsFile $null} | Should -Throw
|
||||
{Import-ZertoVpg -settingsFile ""} | Should -Throw
|
||||
{Import-ZertoVpg -settingsFile @()} | Should -Throw
|
||||
$attrs = (Get-Command $global:function).Parameters['settingsFile'].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,108 +1,55 @@
|
||||
#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" {
|
||||
it "$global:function should have exactly 22 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 22
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'hostName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'datastoreName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'networkName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'Dhcp'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'vraIpAddress'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' }
|
||||
@{ParameterName = 'subnetMask'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' }
|
||||
@{ParameterName = 'defaultGateway'; Type = 'String'; Mandatory = $true; Validation = 'IpAddr' }
|
||||
)
|
||||
|
||||
It "Has a mandatory string host name parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter hostName -Type String
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the host name" {
|
||||
{Install-ZertoVra -hostName $null -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "" -datastoreName "DS01" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
It "Has a mandatory string datastore parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter datastoreName -Type String
|
||||
'IpAddr' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateScript] }.Count | Should -Be 1
|
||||
$attrs.Where{ $_ -is [ValidateScript] }.ScriptBlock | Should -Match '^\$_ \-match \[IPAddress\]\$_'
|
||||
}
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the datastore" {
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName $null -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "" -networkName "MyNetwork" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
It "Has a mandatory string network parameter" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter networkName -Type String
|
||||
}
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
It "Will not accecpt a Null or Empty string for the datastore" {
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName $null -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
{Install-ZertoVra -hostName "MyfirstHost" -datastoreName "DS01" -networkName "" -Dhcp } | Should -Throw "The argument is null or empty"
|
||||
}
|
||||
|
||||
it "Has a switch parameter for setting DHCP" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter Dhcp -Type 'Switch'
|
||||
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the static IP address" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter vraIpAddress -Type String
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the subnet mask" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter subnetMask -Type String
|
||||
}
|
||||
|
||||
it "Has a mandatory string parameter for the default gateway" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter defaultGateway -Type String
|
||||
}
|
||||
|
||||
$cases = `
|
||||
@{invalidIpAddress = "192.168.1.256"}, `
|
||||
@{invalidIpAddress = "192.168.1"}, `
|
||||
@{invalidIpAddress = "String"}, `
|
||||
@{invalidIpAddress = 192.168.1.246}, `
|
||||
@{invalidIpAddress = 32}, `
|
||||
@{invalidIpAddress = ""}, `
|
||||
@{invalidIpAddress = $null}
|
||||
It "IpAddress field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress $invalidIpAddress -subnetMask "255.255.255.0" -defaultGateway "192.168.1.254"} | Should -Throw
|
||||
}
|
||||
|
||||
It "Default Gateway field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask "255.255.255.0" -defaultGateway $invalidIpAddress} | Should -Throw
|
||||
}
|
||||
|
||||
It "Subnet Mask field require valid IP addresses as a String: <invalidIpAddress>" -TestCases $cases {
|
||||
param ( $invalidIpAddress )
|
||||
{Install-ZertoVra -hostName "MyFirstHost" -datastoreName "DS01" -networkName "MyNetwork" -vraIpAddress '192.168.1.100' -subnetMask $invalidIpAddress -defaultGateway "192.168.1.254"} | Should -Throw
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,77 +1,101 @@
|
||||
#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" {
|
||||
it "$global:function should have exactly 20 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 20
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
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
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgName'; Type = 'String'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'checkpointIdentifier'; Type = 'String'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'shutdownPolicy'; Type = 'Int'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'timeToWaitBeforeShutdownInSec'; Type = 'Int'; Mandatory = $false; Validation = 'Range' }
|
||||
@{ParameterName = 'reverseProtection'; Type = 'bool'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'vmName'; Type = 'String[]'; Mandatory = $false; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
||||
)
|
||||
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
it "has a non-mandatory string parameter for the checkpoint" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Type string
|
||||
Get-Command $file.BaseName | Should -HaveParameter checkpointIdentifier -Not -Mandatory
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory string parameter for the commit policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -DefaultValue "Rollback"
|
||||
'Set' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory int parameter for the shutdown policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Type int
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter shutdownPolicy -DefaultValue 0
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory int parameter for the time to wait before force shutdown" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Type int
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -Not -Mandatory
|
||||
Get-Command $file.BaseName | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600
|
||||
'ShouldProcess' {
|
||||
$scriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
$scriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
it "has a non-mandatory bool parameter for the reverse protection policy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type bool
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Not -Mandatory
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
it "has a non-mandatory array string parameter for the named VMs to be failed over" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName -Type string[]
|
||||
Get-Command $file.BaseName | Should -HaveParameter vmName -Not -Mandatory
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
|
||||
it "Supports 'SupportsShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
It "Commit Policy Default Value is 'RollBack'" {
|
||||
Get-Command $global:function | Should -HaveParameter commitPolicy -DefaultValue "Rollback"
|
||||
}
|
||||
|
||||
It "Commit Policy Only Accecpts 'RollBack', 'Commit', or 'None'" {
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'RollBack'
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Commit'
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'None'
|
||||
}
|
||||
|
||||
It "Shutdown Policy Default Value is '0'" {
|
||||
Get-Command $global:function | Should -HaveParameter shutdownPolicy -DefaultValue 0
|
||||
}
|
||||
|
||||
It "Shutdown Policy Only Accecpts 'RollBack', 'Commit', or 'None'" {
|
||||
(Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3
|
||||
(Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 0
|
||||
(Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 1
|
||||
(Get-Command $global:function).Parameters['shutdownPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 2
|
||||
}
|
||||
|
||||
it "Time to wait before shutdown in sec should have a default value of 3600" {
|
||||
Get-Command $global:function | Should -HaveParameter timeToWaitBeforeShutdownInSec -DefaultValue 3600
|
||||
}
|
||||
|
||||
it "Time to wait before shutdown in sec should have a minimum value of 300 and max value of 86400" {
|
||||
(Get-Command $global:function).Parameters['timeToWaitBeforeShutdownInSec'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 300
|
||||
(Get-Command $global:function).Parameters['timeToWaitBeforeShutdownInSec'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 86400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,44 +1,56 @@
|
||||
#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" {
|
||||
|
||||
it "$global:function should have exactly 15 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 15
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'reverseProtection'; Type = 'switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
||||
)
|
||||
|
||||
it "Supports 'ShouldProcess'" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter WhatIf
|
||||
Get-Command $file.BaseName | Should -HaveParameter Confirm
|
||||
$file | Should -FileContentMatch 'SupportsShouldProcess'
|
||||
$file | Should -FileContentMatch '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
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
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a switch parameter for reverse protection" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection
|
||||
Get-Command $file.BaseName | Should -HaveParameter reverseProtection -Type switch
|
||||
'ShouldProcess' {
|
||||
$scriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
$scriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Function Unit Tests" {
|
||||
#TODO
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -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" {
|
||||
|
||||
it "$global:function should have exactly 12 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
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
|
||||
|
||||
@@ -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" {
|
||||
|
||||
it "$global:function should have exactly 12 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 12
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
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
|
||||
|
||||
@@ -1,74 +1,82 @@
|
||||
#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" {
|
||||
it "$global:function should have exactly 20 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 20
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'commitPolicy'; Type = 'String'; Mandatory = $false; Validation = 'Set' }
|
||||
@{ParameterName = 'commitPolicyTimeout'; Type = 'Int'; Mandatory = $false; Validation = 'Range' }
|
||||
@{ParameterName = 'forceShutdown'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'disableReverseProtection'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'keepSourceVms'; Type = 'Switch'; Mandatory = $true; Validation = $null }
|
||||
@{ParameterName = 'ContinueOnPreScriptFailure'; Type = 'Switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
||||
)
|
||||
|
||||
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
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
it "has a non-mandatory string parameter for commitPolicy" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicy -Type string
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "CommitPolicy only accecpts 'Rollback', 'Commit', or 'None'" {
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicy "Rollbackk" } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicy "" } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicy $null } | Should -Throw
|
||||
'Set' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateSet] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "has a non-mandatory int parameter for commitPolicyTimeout" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicyTimeout
|
||||
Get-Command $file.BaseName | Should -HaveParameter commitPolicyTimeout -Type Int
|
||||
'Range' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateRange] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
it "Commit Policy Timeout will only accecpt an int value between 5 minutes and 24 Hours" {
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicyTimeout 150 } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicyTimeout 15000000 } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicyTimeout -1350 } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicyTimeout $null } | Should -Throw
|
||||
{ Invoke-ZertoMove -vpgName "MyVpg" -commitPolicyTimeout "" } | Should -Throw
|
||||
'ShouldProcess' {
|
||||
$scriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
$scriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
it "has a non-mandatory switch parameter for forceShutdown" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter forceShutdown
|
||||
Get-Command $file.BaseName | Should -HaveParameter forceShutdown -Type Switch
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
it "has a mandatory switch parameter for disableReverseProtection" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter disableReverseProtection
|
||||
Get-Command $file.BaseName | Should -HaveParameter disableReverseProtection -Type Switch
|
||||
Get-Command $file.BaseName | Should -HaveParameter disableReverseProtection -Mandatory
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it "has a non-mandatory switch parameter for keepSourceVms" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter keepSourceVms
|
||||
Get-Command $file.BaseName | Should -HaveParameter keepSourceVms -Type Switch
|
||||
Get-Command $file.BaseName | Should -HaveParameter keepSourceVms -Mandatory
|
||||
It "Commit Policy Only Accecpts 'RollBack', 'Commit', or 'None'" {
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -HaveCount 3
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'RollBack'
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'Commit'
|
||||
(Get-Command $global:function).Parameters['commitPolicy'].Attributes.Where{ $_ -is [ValidateSet] }.ValidValues | Should -Contain 'None'
|
||||
}
|
||||
|
||||
it "has a non-mandatory switch parameter for ContinueOnPreScriptFailure" {
|
||||
Get-Command $file.BaseName | Should -HaveParameter ContinueOnPreScriptFailure
|
||||
Get-Command $file.BaseName | Should -HaveParameter ContinueOnPreScriptFailure -Type Switch
|
||||
it "Commit Policy Timeout should have a minimum value of 300 and max value of 86400" {
|
||||
(Get-Command $global:function).Parameters['commitPolicyTimeout'].Attributes.Where{ $_ -is [ValidateRange] }.MinRange | Should -Be 300
|
||||
(Get-Command $global:function).Parameters['commitPolicyTimeout'].Attributes.Where{ $_ -is [ValidateRange] }.MaxRange | Should -Be 86400
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,28 +1,56 @@
|
||||
#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" {
|
||||
|
||||
it "$global:function should have exactly 16 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 16
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
$ParameterTestCases = @(
|
||||
@{ParameterName = 'vpgName'; Type = 'String[]'; Mandatory = $true; Validation = 'NotNullOrEmpty' }
|
||||
@{ParameterName = 'reverseProtection'; Type = 'switch'; Mandatory = $false; Validation = $null }
|
||||
@{ParameterName = 'whatIf'; Type = 'Switch'; Mandatory = $false; Validation = 'ShouldProcess' }
|
||||
)
|
||||
|
||||
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
|
||||
It "<ParameterName> parameter is of <Type> type" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Type, $Mandatory, $Validation)
|
||||
Get-Command $global:function | Should -HaveParameter $ParameterName -Mandatory:$Mandatory -Type $Type
|
||||
}
|
||||
|
||||
It "<ParameterName> parameter has correct validation setting" -TestCases $ParameterTestCases {
|
||||
param($ParameterName, $Validation)
|
||||
Switch ($Validation) {
|
||||
'NotNullOrEmpty' {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.Where{ $_ -is [ValidateNotNullOrEmpty] }.Count | Should -Be 1
|
||||
}
|
||||
|
||||
'ShouldProcess' {
|
||||
$scriptBlock = (Get-Command $global:function).ScriptBlock
|
||||
$scriptBlock | Should -match 'SupportsShouldProcess'
|
||||
$scriptBlock | Should -match '\$PSCmdlet\.ShouldProcess\(.+\)'
|
||||
}
|
||||
|
||||
$null {
|
||||
$attrs = (Get-Command $global:function).Parameters[$ParameterName].Attributes
|
||||
$attrs.TypeId.Count | Should -Be 2
|
||||
}
|
||||
|
||||
default {
|
||||
$true | should be $false -Because "No Validation Selected. Review test cases"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -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" {
|
||||
|
||||
it "$global:function should have exactly 14 parameters defined" {
|
||||
(get-command $global:function).Parameters.Count | Should -Be 14
|
||||
}
|
||||
|
||||
Context "$($file.BaseName)::Parameter Unit Tests" {
|
||||
|
||||
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
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"apiRequestResults": "",
|
||||
"Headers": {
|
||||
"Cache-Control": [
|
||||
"no-cache"
|
||||
],
|
||||
"Server": [
|
||||
"Microsoft-HTTPAPI/2.0"
|
||||
],
|
||||
"x-zerto-session": [
|
||||
"e34da0b0-4bc2-4cda-b316-0384e35bdca5"
|
||||
],
|
||||
"X-Content-Type-Options": [
|
||||
"nosniff"
|
||||
],
|
||||
"Date": [
|
||||
"Thu, 11 Jul 2019 19:05:40 GMT"
|
||||
],
|
||||
"Content-Length": [
|
||||
"0"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"DatastoreClusterIdentifier": null,
|
||||
"DatastoreClusterName": null,
|
||||
"DatastoreIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.datastore-21",
|
||||
"DatastoreName": "datastore1 (2)",
|
||||
"HostIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.host-18",
|
||||
"HostVersion": "6.7",
|
||||
"IpAddress": "192.168.10.110",
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vras/5377857665828094938",
|
||||
"identifier": "5377857665828094938",
|
||||
"rel": null,
|
||||
"type": "VraApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vras/5377857665828094938",
|
||||
"rel": "self",
|
||||
"type": "VraApi"
|
||||
},
|
||||
"MemoryInGB": 1,
|
||||
"NetworkIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.network-22",
|
||||
"NetworkName": "VM Network",
|
||||
"Progress": 0,
|
||||
"ProtectedCounters": {
|
||||
"Vms": 0,
|
||||
"Volumes": 0,
|
||||
"Vpgs": 0
|
||||
},
|
||||
"RecoveryCounters": {
|
||||
"Vms": 0,
|
||||
"Volumes": 0,
|
||||
"Vpgs": 0
|
||||
},
|
||||
"SelfProtectedVpgs": 0,
|
||||
"Status": 0,
|
||||
"VraAlerts": {
|
||||
"VraAlertsStatus": 0
|
||||
},
|
||||
"VraGroup": "default_group",
|
||||
"VraIdentifier": 5377857665828094938,
|
||||
"VraIdentifierStr": "5377857665828094938",
|
||||
"VraName": "Z-VRA-ncesx1.nc.lab",
|
||||
"VraNetworkDataApi": {
|
||||
"DefaultGateway": "",
|
||||
"SubnetMask": "255.255.255.0",
|
||||
"VraIPAddress": "192.168.10.110",
|
||||
"VraIPConfigurationTypeApi": "Dhcp"
|
||||
},
|
||||
"VraVersion": "7.0"
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"DatastoreClusterIdentifier": null,
|
||||
"DatastoreClusterName": null,
|
||||
"DatastoreIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.datastore-19",
|
||||
"DatastoreName": "datastore1",
|
||||
"HostIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.host-15",
|
||||
"HostVersion": "6.7",
|
||||
"IpAddress": "192.168.10.15",
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vras/5377857665828093654",
|
||||
"identifier": "5377857665828093654",
|
||||
"rel": null,
|
||||
"type": "VraApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vras/5377857665828093654",
|
||||
"rel": "self",
|
||||
"type": "VraApi"
|
||||
},
|
||||
"MemoryInGB": 1,
|
||||
"NetworkIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.network-22",
|
||||
"NetworkName": "VM Network",
|
||||
"Progress": 0,
|
||||
"ProtectedCounters": {
|
||||
"Vms": 0,
|
||||
"Volumes": 0,
|
||||
"Vpgs": 0
|
||||
},
|
||||
"RecoveryCounters": {
|
||||
"Vms": 0,
|
||||
"Volumes": 0,
|
||||
"Vpgs": 0
|
||||
},
|
||||
"SelfProtectedVpgs": 0,
|
||||
"Status": 0,
|
||||
"VraAlerts": {
|
||||
"VraAlertsStatus": 0
|
||||
},
|
||||
"VraGroup": "default_group",
|
||||
"VraIdentifier": 5377857665828093654,
|
||||
"VraIdentifierStr": "5377857665828093654",
|
||||
"VraName": "Z-VRA-ncesx2.nc.lab",
|
||||
"VraNetworkDataApi": {
|
||||
"DefaultGateway": "192.168.10.254",
|
||||
"SubnetMask": "255.255.255.0",
|
||||
"VraIPAddress": "192.168.10.15",
|
||||
"VraIPConfigurationTypeApi": "Static"
|
||||
},
|
||||
"VraVersion": "7.0"
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"ActiveProcessesApi": {
|
||||
"RunningFailOverTestApi": null
|
||||
},
|
||||
"ActualRPO": 7,
|
||||
"BackupEnabled": false,
|
||||
"ConfiguredRpoSeconds": 300,
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"FailSafeHistory": {
|
||||
"ActualFailSafeHistory": 60,
|
||||
"ConfiguredFailSafeHistory": 240,
|
||||
"FailSafeDescription": ""
|
||||
},
|
||||
"HistoryStatusApi": {
|
||||
"ActualHistoryInMinutes": 92,
|
||||
"ConfiguredHistoryInMinutes": 1440,
|
||||
"EarliestCheckpoint": {
|
||||
"CheckpointIdentifier": "786",
|
||||
"Tag": null,
|
||||
"TimeStamp": "2019-07-20T19:30:19Z"
|
||||
}
|
||||
},
|
||||
"IOPs": 13,
|
||||
"LastTest": null,
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vpgs/57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"identifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": null,
|
||||
"type": "VpgApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vpgs/57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": "self",
|
||||
"type": "VpgApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"Priority": 1,
|
||||
"ProgressPercentage": 0,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 336118,
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"ServiceProfile": null,
|
||||
"ServiceProfileIdentifier": null,
|
||||
"ServiceProfileName": "",
|
||||
"SourceSite": "WCHL - NC",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "WCHL - CA",
|
||||
"ThroughputInMB": 0.27197265625,
|
||||
"UsedStorageInMB": 245465,
|
||||
"VmsCount": 4,
|
||||
"VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"VpgName": "ExportStuff",
|
||||
"Zorg": {
|
||||
"href": "https://192.168.10.20:9669/v1/zorgs/00000000-0000-0000-0000-000000000000",
|
||||
"identifier": "00000000-0000-0000-0000-000000000000",
|
||||
"rel": null,
|
||||
"type": "ZorgApi"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"BandwidthThrottlingInMBs": -1,
|
||||
"ContactEmail": "vSphere-Site01@zerto.com",
|
||||
"ContactName": "vSphere-Site01@zerto.com",
|
||||
"ContactPhone": "066-6666666",
|
||||
"IpAddress": "192.168.200.1",
|
||||
"IsReplicationToSelfEnabled": true,
|
||||
"Link": {
|
||||
"href": "https://192.168.222.1:7669/v1/localsite",
|
||||
"identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"Location": "vSphere-Site01",
|
||||
"SiteIdentifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
|
||||
"SiteName": "vSphere-Site01 at Zerto",
|
||||
"SiteType": "VCenter",
|
||||
"UtcOffsetInMinutes": -240,
|
||||
"Version": "7.0.0"
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
[
|
||||
{
|
||||
"ActualRPO": 7,
|
||||
"EnabledActions": {
|
||||
"IsFlrEnabled": true
|
||||
},
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"HardwareVersion": "vmx-15",
|
||||
"IOPs": 2,
|
||||
"IsVmExists": true,
|
||||
"JournalHardLimit": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 153600
|
||||
},
|
||||
"JournalUsedStorageMb": 640,
|
||||
"JournalWarningThreshold": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 115200
|
||||
},
|
||||
"LastTest": null,
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": null,
|
||||
"type": "VmApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": "self",
|
||||
"type": "VmApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"OutgoingBandWidthInMbps": 0.001953125,
|
||||
"Priority": 1,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 77906,
|
||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"SourceSite": "WCHL - NC",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "WCHL - CA",
|
||||
"ThroughputInMB": 0,
|
||||
"UsedStorageInMB": 77906,
|
||||
"VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-38",
|
||||
"VmName": "ncesx3.nc.lab",
|
||||
"Volumes": [
|
||||
{
|
||||
"VmVolumeIdentifier": "scsi:0:0"
|
||||
}
|
||||
],
|
||||
"VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"VpgName": "ExportStuff"
|
||||
},
|
||||
{
|
||||
"ActualRPO": 7,
|
||||
"EnabledActions": {
|
||||
"IsFlrEnabled": true
|
||||
},
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"HardwareVersion": "vmx-15",
|
||||
"IOPs": 1,
|
||||
"IsVmExists": true,
|
||||
"JournalHardLimit": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 153600
|
||||
},
|
||||
"JournalUsedStorageMb": 609,
|
||||
"JournalWarningThreshold": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 115200
|
||||
},
|
||||
"LastTest": null,
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": null,
|
||||
"type": "VmApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": "self",
|
||||
"type": "VmApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"OutgoingBandWidthInMbps": 0.0009765625,
|
||||
"Priority": 1,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 77906,
|
||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"SourceSite": "WCHL - NC",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "WCHL - CA",
|
||||
"ThroughputInMB": 0,
|
||||
"UsedStorageInMB": 77906,
|
||||
"VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-37",
|
||||
"VmName": "ncesx2.nc.lab",
|
||||
"Volumes": [
|
||||
{
|
||||
"VmVolumeIdentifier": "scsi:0:0"
|
||||
}
|
||||
],
|
||||
"VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"VpgName": "ExportStuff"
|
||||
},
|
||||
{
|
||||
"ActualRPO": 7,
|
||||
"EnabledActions": {
|
||||
"IsFlrEnabled": true
|
||||
},
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"HardwareVersion": "vmx-15",
|
||||
"IOPs": 2,
|
||||
"IsVmExists": true,
|
||||
"JournalHardLimit": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 153600
|
||||
},
|
||||
"JournalUsedStorageMb": 634,
|
||||
"JournalWarningThreshold": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 115200
|
||||
},
|
||||
"LastTest": null,
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": null,
|
||||
"type": "VmApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": "self",
|
||||
"type": "VmApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"OutgoingBandWidthInMbps": 0.00146484375,
|
||||
"Priority": 1,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 77906,
|
||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"SourceSite": "WCHL - NC",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "WCHL - CA",
|
||||
"ThroughputInMB": 0,
|
||||
"UsedStorageInMB": 77906,
|
||||
"VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-36",
|
||||
"VmName": "ncesx1.nc.lab",
|
||||
"Volumes": [
|
||||
{
|
||||
"VmVolumeIdentifier": "scsi:0:0"
|
||||
}
|
||||
],
|
||||
"VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"VpgName": "ExportStuff"
|
||||
},
|
||||
{
|
||||
"ActualRPO": 7,
|
||||
"EnabledActions": {
|
||||
"IsFlrEnabled": true
|
||||
},
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"HardwareVersion": "vmx-14",
|
||||
"IOPs": 5,
|
||||
"IsVmExists": true,
|
||||
"JournalHardLimit": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 153600
|
||||
},
|
||||
"JournalUsedStorageMb": 642,
|
||||
"JournalWarningThreshold": {
|
||||
"LimitType": 1,
|
||||
"LimitValue": 115200
|
||||
},
|
||||
"LastTest": null,
|
||||
"Link": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"identifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": null,
|
||||
"type": "VmApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.10.20:9669/v1/vms/d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26?VpgIdentifier=57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"rel": "self",
|
||||
"type": "VmApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"OutgoingBandWidthInMbps": 0.01953125,
|
||||
"Priority": 1,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.10.20:9669/v1/localsite",
|
||||
"identifier": "9e09efa0-0d00-46ed-929b-f86273b28205",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 102400,
|
||||
"RecoveryHostIdentifier": "f45d81e4-4ff5-4376-a5c8-20ffe8d52431.host-15",
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.10.20:9669/v1/peersites/057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"identifier": "057cab27-f02a-443a-989d-7f14341fa9c3",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"SourceSite": "WCHL - NC",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "WCHL - CA",
|
||||
"ThroughputInMB": 0,
|
||||
"UsedStorageInMB": 11747,
|
||||
"VmIdentifier": "d4a6a1d5-79e9-4308-990a-7c3e616f0908.vm-26",
|
||||
"VmName": "nczvm.nc.lab",
|
||||
"Volumes": [
|
||||
{
|
||||
"VmVolumeIdentifier": "scsi:0:0"
|
||||
}
|
||||
],
|
||||
"VpgIdentifier": "57f502ff-3c41-4aff-b20a-6638205b73cd",
|
||||
"VpgName": "ExportStuff"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
7e79035e-fb8c-47fe-815c-12ddd41708e6.3e4cdd0d-1064-4022-921f-6265ad6d335a
|
||||
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"ActiveProcessesApi": {
|
||||
"RunningFailOverTestApi": null
|
||||
},
|
||||
"ActualRPO": 6,
|
||||
"BackupEnabled": false,
|
||||
"ConfiguredRpoSeconds": 300,
|
||||
"Entities": {
|
||||
"Protected": 0,
|
||||
"Recovery": 0,
|
||||
"Source": 0,
|
||||
"Target": 0
|
||||
},
|
||||
"FailSafeHistory": {
|
||||
"ActualFailSafeHistory": 60,
|
||||
"ConfiguredFailSafeHistory": 60,
|
||||
"FailSafeDescription": ""
|
||||
},
|
||||
"HistoryStatusApi": {
|
||||
"ActualHistoryInMinutes": 225,
|
||||
"ConfiguredHistoryInMinutes": 60,
|
||||
"EarliestCheckpoint": {
|
||||
"CheckpointIdentifier": "166834",
|
||||
"Tag": null,
|
||||
"TimeStamp": "2019-07-11T13:47:23Z"
|
||||
}
|
||||
},
|
||||
"IOPs": 8,
|
||||
"LastTest": "2019-07-11T16:51:07.022Z",
|
||||
"Link": {
|
||||
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||
"identifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||
"rel": null,
|
||||
"type": "VpgApi"
|
||||
},
|
||||
"Link_{0}": {
|
||||
"href": "https://192.168.222.1:7669/v1/vpgs/99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||
"rel": "self",
|
||||
"type": "VpgApi"
|
||||
},
|
||||
"OrganizationName": "",
|
||||
"Priority": 1,
|
||||
"ProgressPercentage": 0,
|
||||
"ProtectedSite": {
|
||||
"href": "https://192.168.222.1:7669/v1/localsite",
|
||||
"identifier": "63a62dc2-ef6f-45aa-809f-9dbaeb8c06cf",
|
||||
"rel": null,
|
||||
"type": "LocalSiteApi"
|
||||
},
|
||||
"ProvisionedStorageInMB": 400,
|
||||
"RecoverySite": {
|
||||
"href": "https://192.168.222.1:7669/v1/peersites/3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
||||
"identifier": "3e4cdd0d-1064-4022-921f-6265ad6d335a",
|
||||
"rel": null,
|
||||
"type": "PeerSiteApi"
|
||||
},
|
||||
"ServiceProfile": null,
|
||||
"ServiceProfileIdentifier": null,
|
||||
"ServiceProfileName": "",
|
||||
"SourceSite": "vSphere-Site01 at Zerto",
|
||||
"Status": 1,
|
||||
"SubStatus": 0,
|
||||
"TargetSite": "vSphere-Site02 at Zerto",
|
||||
"ThroughputInMB": 58.55859375,
|
||||
"UsedStorageInMB": 400,
|
||||
"VmsCount": 4,
|
||||
"VpgIdentifier": "99c460c1-a4ec-48dd-8921-bbcca9cd29b9",
|
||||
"VpgName": "Exchange",
|
||||
"Zorg": {
|
||||
"href": "https://192.168.222.1:7669/v1/zorgs/00000000-0000-0000-0000-000000000000",
|
||||
"identifier": "00000000-0000-0000-0000-000000000000",
|
||||
"rel": null,
|
||||
"type": "ZorgApi"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"type": "Bearer",
|
||||
"token": "N074r34l70k3n"
|
||||
}
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#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' {
|
||||
|
||||
Context "$global:function::Parameter Unit Tests" {
|
||||
|
||||
}
|
||||
|
||||
Context "$global:function::Parameter Functional Tests" {
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Remove-Variable -Name here -Scope Global
|
||||
Remove-Variable -Name function -Scope Global
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user