-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeployButton.Tests.ps1
63 lines (51 loc) · 2.38 KB
/
deployButton.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#requires -RunAsAdministrator
#requires -Module Pester
<#
.Synopsis
Run these tests after deploying the DscPush Workshop configurations to infrastructure.
The VMs will need to reboot a few times before the Test-DscConfiguration cmdlet comes back true.
.Parameter Credential
The administrator credential for your image.
.Parameter vmNetworkAddressList
The IP addresses of the VMs you built. Hopefully with code...
.EXAMPLE
$credential = get-credential administrator
.\deployButton.Tests.ps1 -Credential $credential -VmNetworkAddressList @("192.0.0.30")
#>
param(
[Parameter(Mandatory)]
[pscredential]
$Credential,
[Parameter(Mandatory)]
[string[]]
$VmNetworkAddressList
)
Describe "DscPush Workshop Deployment" {
Context "VM DSC State" {
#region Prepare for test
$cimSessions = New-CimSession -ComputerName $VmNetworkAddressList -Credential $Credential
Stop-DscConfiguration -CimSession $cimSessions -WarningAction Ignore
#endregion
#populate the testCases var for Pester to run and report on each target
$testCases = $cimSessions.ForEach({@{cimSession = $_;ComputerName=$_.ComputerName}})
It "<ComputerName> should run Start-DscConfiguration successfully" -TestCases $testCases {
param ( $cimSession )
{ Start-DscConfiguration -CimSession $cimSession -Wait -UseExisting -ErrorAction Stop } | Should Not Throw
}
It "<ComputerName> should return 'Success' from Get-DscConfigurationStatus" -TestCases $testCases {
param ( $cimSession )
$testResult = Get-DscConfigurationStatus -CimSession $cimSession -ErrorAction Stop
"$($testResult.ResourcesNotInDesiredState.ResourceID)" | Should Be ""
$testResult.Status | Should Be 'Success'
}
It "<ComputerName> should return True from Test-DscConfiguration" -TestCases $testCases {
param ( $cimSession )
$testDscReturn = Test-DscConfiguration -CimSession $cimSession -ErrorAction Stop
$testDscReturn | Should Be 'True'
}
It "<ComputerName> should run Get-DscConfiguration without throwing" -TestCases $testCases {
param ( $cimSession )
{ Get-DscConfiguration -CimSession $cimSession -ErrorAction Stop } | Should Not Throw
}
}
}