From 3403db0eadeb417246e3dce12cddc58c8b900a64 Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Fri, 15 Jul 2016 16:43:32 -0700 Subject: [PATCH 1/2] Pester VC Connection test Connection and modules tests for VC in pester --- Pester/Test Connection to VC.ps1 | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Pester/Test Connection to VC.ps1 diff --git a/Pester/Test Connection to VC.ps1 b/Pester/Test Connection to VC.ps1 new file mode 100644 index 0000000..cf017bc --- /dev/null +++ b/Pester/Test Connection to VC.ps1 @@ -0,0 +1,40 @@ +<# +Script name: Test Connection to VC.ps1 +Created on: 07/15/2016 +Author: Alan Renouf, @alanrenouf +Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection and disconnection can be made to a vCenter +Dependencies: Pester Module +#> + +$VCNAME = "MyVC@Mydomain.local" +$VCUSER = "Administrator@vsphere.local" +$VCPASS = "Admin!23" + +Describe "PowerCLI Tests" { + It "Importing PowerCLI Modules" { + Get-Module VMware* | Foreach { + Write-Host "Importing Module $($_.name) Version $($_.Version)" + $_ | Import-Module + Get-Module $_ | Should Be $true + } + } +} + +Describe "Connect-VIServer Tests" { + + $connection = Connect-VIServer $VCName -User $VCUser -password $VCPass + It "Connection is active" { + $Global:DefaultVIServer[0].isconnected | Should Be $true + } + + It "Checking connected server name is $VCName" { + $Global:DefaultVIServer[0].name | Should Be $VCName + } +} + +Describe "Disconnect-VIServer Tests" { + It "Disconnect from $VCName" { + Disconnect-VIServer $VCName -confirm:$false + $Global:DefaultVIServer | Should Be $null + } +} \ No newline at end of file From 99673b1dfa9791db6fda18f78f89ec94e45f6dbe Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Fri, 15 Jul 2016 16:45:03 -0700 Subject: [PATCH 2/2] removed pester test so it gets approval --- Pester/Test Connection to VC.ps1 | 40 -------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 Pester/Test Connection to VC.ps1 diff --git a/Pester/Test Connection to VC.ps1 b/Pester/Test Connection to VC.ps1 deleted file mode 100644 index cf017bc..0000000 --- a/Pester/Test Connection to VC.ps1 +++ /dev/null @@ -1,40 +0,0 @@ -<# -Script name: Test Connection to VC.ps1 -Created on: 07/15/2016 -Author: Alan Renouf, @alanrenouf -Description: The purpose of this pester test is to ensure the PowerCLI modules are imported and a connection and disconnection can be made to a vCenter -Dependencies: Pester Module -#> - -$VCNAME = "MyVC@Mydomain.local" -$VCUSER = "Administrator@vsphere.local" -$VCPASS = "Admin!23" - -Describe "PowerCLI Tests" { - It "Importing PowerCLI Modules" { - Get-Module VMware* | Foreach { - Write-Host "Importing Module $($_.name) Version $($_.Version)" - $_ | Import-Module - Get-Module $_ | Should Be $true - } - } -} - -Describe "Connect-VIServer Tests" { - - $connection = Connect-VIServer $VCName -User $VCUser -password $VCPass - It "Connection is active" { - $Global:DefaultVIServer[0].isconnected | Should Be $true - } - - It "Checking connected server name is $VCName" { - $Global:DefaultVIServer[0].name | Should Be $VCName - } -} - -Describe "Disconnect-VIServer Tests" { - It "Disconnect from $VCName" { - Disconnect-VIServer $VCName -confirm:$false - $Global:DefaultVIServer | Should Be $null - } -} \ No newline at end of file