Update function to global variable

This commit is contained in:
Wes Carroll
2019-07-14 20:36:32 -04:00
parent dd144d3c47
commit 235434fe20
5 changed files with 51 additions and 38 deletions
@@ -1,19 +1,19 @@
#Requires -Modules Pester
$global:here = (Split-Path -Parent $MyInvocation.MyCommand.Path)
$script:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
$global:function = ((Split-Path -leaf $MyInvocation.MyCommand.Path).Split('.'))[0]
Describe $script:function -Tag 'Unit', 'Source', 'Built' {
Describe $global:function -Tag 'Unit', 'Source', 'Built' {
BeforeAll {
$script:ScriptBlock = (Get-Command $script:function).ScriptBlock
$script:ScriptBlock = (Get-Command $global:function).ScriptBlock
}
Context "$($script:function)::Parameter Unit Tests" {
Context "$($global:function)::Parameter Unit Tests" {
it "Does not take any parameters" {
(get-command disconnect-zertoserver).parameters.count | Should -BeExactly 11
}
}
Context "$($script:function)::Function Unit Tests" {
Context "$($global:function)::Function Unit Tests" {
InModuleScope -ModuleName ZertoApiWrapper {
Mock -ModuleName ZertoApiWrapper -CommandName Invoke-ZertoRestRequest {
# Attempted to Mock this per the Mock Below and it blew up. Auth Headers Returns a Dictionary
@@ -38,3 +38,6 @@ Describe $script:function -Tag 'Unit', 'Source', 'Built' {
}
}
}
Remove-Variable -Name function -Scope Global
Remove-Variable -Name here -Scope Global