Skip to content

Commit

Permalink
Check for error correctly in integrationt ests
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueHO committed Jul 20, 2018
1 parent d34d315 commit da4ada9
Showing 1 changed file with 25 additions and 19 deletions.
Expand Up @@ -24,6 +24,8 @@ $TestEnvironment = Initialize-TestEnvironment `
-TestType Integration
#endregion

Import-Module -Name (Join-Path -Path (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath 'TestHelpers') -ChildPath 'CommonTestHelper.psm1') -Global

# Using try/finally to always cleanup even if something awful happens.
try
{
Expand Down Expand Up @@ -51,16 +53,16 @@ try
$configData = @{
AllNodes = @(
@{
NodeName = 'localhost'
CAServerFQDN = $caServerFQDN
CARootName = $caRootName
NodeName = 'localhost'
CAServerFQDN = $caServerFQDN
CARootName = $caRootName
RetryIntervalSeconds = 1
RetryCount = 2
RetryCount = 2
}
)
}

It 'Should compile and apply the MOF without throwing' {
It 'Should compile and apply the MOF without throwing an exception' {
{
& "$($script:DSCResourceName)_Config" `
-OutputPath $TestDrive `
Expand All @@ -72,7 +74,7 @@ try
-Wait `
-Verbose `
-Force `
-ErrorAction SilentlyContinue
-ErrorAction Stop
} | Should -Not -Throw
}

Expand Down Expand Up @@ -100,31 +102,35 @@ try
$configData = @{
AllNodes = @(
@{
NodeName = 'localhost'
CAServerFQDN = $caServerFQDN
CARootName = $caRootName
NodeName = 'localhost'
CAServerFQDN = $caServerFQDN
CARootName = $caRootName
RetryIntervalSeconds = 1
RetryCount = 2
RetryCount = 2
}
)
}

It 'Should compile and apply the MOF without throwing' {
It 'Should compile the MOF without throwing an exception' {
{
& "$($script:DSCResourceName)_Config" `
-OutputPath $TestDrive `
-ConfigurationData $configData

Start-DscConfiguration `
-Path $TestDrive `
-ComputerName localhost `
-Wait `
-Verbose `
-Force `
-ErrorAction SilentlyContinue
} | Should -Not -Throw
}

It 'Should apply the MOF throwing an exception' {
{
Start-DscConfiguration `
-Path $TestDrive `
-ComputerName localhost `
-Wait `
-Verbose `
-Force `
-ErrorAction Stop
} | Should -Throw
}

It 'Should be able to call Get-DscConfiguration without throwing' {
{ Get-DscConfiguration -Verbose -ErrorAction Stop } | Should -Not -Throw
}
Expand Down

0 comments on commit da4ada9

Please sign in to comment.