From 29578c6305c8cc7c7f381798f22553f8bd9d7b65 Mon Sep 17 00:00:00 2001 From: Alan Renouf Date: Thu, 20 Apr 2017 16:24:40 -0700 Subject: [PATCH] updated pester tests for CIS cmdlets --- ...nect-CISServer Connection to VC.Tests.ps1} | 0 ...nnect-VIServer Connection to VC.Tests.ps1} | 0 Pester/Test Get-CISService.Tests.ps1 | 49 +++++++++++++++++++ ...Test Disconnect-CISServer to VC.Tests.ps1} | 0 ... Test Disconnect-VIServer to VC.Tests.ps1} | 0 5 files changed, 49 insertions(+) rename Pester/{Test Connect-CISServer Connection to VC.Tests.ps1 => 00 Test Connect-CISServer Connection to VC.Tests.ps1} (100%) rename Pester/{Test Connect-VIServer Connection to VC.Tests.ps1 => 00 Test Connect-VIServer Connection to VC.Tests.ps1} (100%) create mode 100644 Pester/Test Get-CISService.Tests.ps1 rename Pester/{Test Disconnect-CISServer to VC.Tests.ps1 => ZZ Test Disconnect-CISServer to VC.Tests.ps1} (100%) rename Pester/{Test Disconnect-VIServer to VC.Tests.ps1 => ZZ Test Disconnect-VIServer to VC.Tests.ps1} (100%) diff --git a/Pester/Test Connect-CISServer Connection to VC.Tests.ps1 b/Pester/00 Test Connect-CISServer Connection to VC.Tests.ps1 similarity index 100% rename from Pester/Test Connect-CISServer Connection to VC.Tests.ps1 rename to Pester/00 Test Connect-CISServer Connection to VC.Tests.ps1 diff --git a/Pester/Test Connect-VIServer Connection to VC.Tests.ps1 b/Pester/00 Test Connect-VIServer Connection to VC.Tests.ps1 similarity index 100% rename from Pester/Test Connect-VIServer Connection to VC.Tests.ps1 rename to Pester/00 Test Connect-VIServer Connection to VC.Tests.ps1 diff --git a/Pester/Test Get-CISService.Tests.ps1 b/Pester/Test Get-CISService.Tests.ps1 new file mode 100644 index 0000000..17d18b5 --- /dev/null +++ b/Pester/Test Get-CISService.Tests.ps1 @@ -0,0 +1,49 @@ +<# +Script name: Test Connect-CISService.Tests.ps1 +Created on: 04/20/2017 +Author: Alan Renouf, @alanrenouf +Description: The purpose of this pester test is to ensure the CIS Service cmdlet works correctly +Dependencies: Pester Module +Example run: + +Invoke-Pester -Script @{ Path = '.\Test Get-CISService.ps1' } + +#> + +Describe "Checking PowerCLI Cmdlets available" { + $cmdletname = "Get-CISService" + It "Checking $cmdletname is available" { + $command = Get-Command $cmdletname + $command | Select Name, Version + $command.Name| Should Be $cmdletname + } +} + +Describe "Get-CISService Tests for services" { + + It "Checking CIS connection is active" { + $Global:DefaultCISServers[0].isconnected | Should Be $true + } + + It "Checking Get-CISService returns services" { + Get-CISService | Should Be $true + } + + # Checking some known services which have a Get Method + $servicestocheck = "com.vmware.appliance.system.version", "com.vmware.appliance.health.system" + Foreach ($service in $servicestocheck) { + It "Checking $service get method returns data" { + Get-CisService -Name $service | Should Be $true + (Get-CisService -Name $service).get() | Should Be $true + } + } + + # Checking some known services which have a List Method + $servicestocheck = "com.vmware.vcenter.folder", "com.vmware.vcenter.vm" + Foreach ($service in $servicestocheck) { + It "Checking $service list method returns data" { + Get-CisService -Name $service | Should Be $true + (Get-CisService -Name $service).list() | Should Be $true + } + } +} \ No newline at end of file diff --git a/Pester/Test Disconnect-CISServer to VC.Tests.ps1 b/Pester/ZZ Test Disconnect-CISServer to VC.Tests.ps1 similarity index 100% rename from Pester/Test Disconnect-CISServer to VC.Tests.ps1 rename to Pester/ZZ Test Disconnect-CISServer to VC.Tests.ps1 diff --git a/Pester/Test Disconnect-VIServer to VC.Tests.ps1 b/Pester/ZZ Test Disconnect-VIServer to VC.Tests.ps1 similarity index 100% rename from Pester/Test Disconnect-VIServer to VC.Tests.ps1 rename to Pester/ZZ Test Disconnect-VIServer to VC.Tests.ps1