Update Checkpoint-ZertoVpg.Tests.ps1

This commit is contained in:
Wes Carroll
2019-03-29 21:54:24 -04:00
parent 49798b190d
commit 0114c73706
+24 -1
View File
@@ -9,11 +9,34 @@ Get-Module -Name ZertoApiWrapper | Remove-Module -Force
Import-Module $moduleFile -Force
Describe $file.BaseName -Tag 'Unit' {
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
return "3b687246-ac63-40da-9a59-b99863769eb0.928a122b-1763-4664-ad37-cc00bb883f2f"
}
Mock -ModuleName ZertoApiWrapper -CommandName get-zertovpg {
return @{vpgIdentifier = "dddf2fa8-79e2-4e4f-a83b-f66676afea64"}
}
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
}
it "should return a 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"
}
it "should require a tag name" {
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName ""} | Should -Throw
}
it "should NOT support '-WhatIf'" {
{Checkpoint-ZertoVpg -vpgName "MyVpg" -checkpointName "Checkers" -whatif} | Should -Throw
}
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest
Assert-MockCalled -ModuleName ZertoApiWrapper -CommandName Get-ZertoVpg
}