Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Borgquite committed Jun 14, 2024
1 parent d7bdaec commit b6f9e32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 0 additions & 2 deletions Tests/Helpers/ImitateUpdateServicesModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ function Get-WsusServerTemplate

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetUpdateClassification -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value {}

$WsusServer | Add-Member -MemberType ScriptMethod -Name GetComputerTargetGroups -Value $ComputerTargetGroups

$WsusServer | Add-Member -MemberType ScriptMethod -Name DeleteInstallApprovalRule -Value {}
Expand Down
20 changes: 12 additions & 8 deletions Tests/Unit/MSFT_UpdateServicesComputerTargetGroup.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ $TestEnvironment = Initialize-TestEnvironment `
-ResourceType 'Mof' `
-TestType Unit

#region Pester Test Initialization
Import-Module $PSScriptRoot\..\Helpers\ImitateUpdateServicesModule.psm1 -force -ErrorAction Stop

#endregion HEADER


Expand All @@ -20,11 +23,6 @@ try
{
InModuleScope $script:DSCResourceName {

#region Pester Test Initialization
Import-Module $PSScriptRoot\..\Helpers\ImitateUpdateServicesModule.psm1 -Force

#endregion

#region Function Get-ComputerTargetGroupPath
Describe "MSFT_UpdateServicesComputerTargetGroup\Get-ComputerTargetGroupPath." {
$WsusServer = Get-WsusServer
Expand Down Expand Up @@ -55,7 +53,9 @@ try
if (Test-Path -Path variable:script:resource) { Remove-Variable -Scope 'script' -Name 'resource' }
}

Mock -CommandName Write-Verbose -MockWith {}
BeforeAll {
Mock -CommandName Write-Verbose -MockWith {}
}

Context 'An error occurs retrieving WSUS Server configuration information.' {
Mock -CommandName Get-WsusServer -MockWith { throw 'An error occurred.' }
Expand Down Expand Up @@ -121,7 +121,9 @@ try

#region Function Test-TargetResource
Describe "MSFT_UpdateServicesComputerTargetGroup\Test-TargetResource." {
Mock -CommandName Write-Verbose -MockWith {}
BeforeAll {
Mock -CommandName Write-Verbose -MockWith {}
}

Context 'The Computer Target Group "Desktops" is "Present" at Path "All Computers/Workstations" which is the desired state.' {
Mock -CommandName Get-TargetResource -MockWith {
Expand Down Expand Up @@ -211,7 +213,9 @@ try
if (Test-Path -Path variable:script:resource) { Remove-Variable -Scope 'script' -Name 'resource' }
}

Mock -CommandName Write-Verbose -MockWith {}
BeforeAll {
Mock -CommandName Write-Verbose -MockWith {}
}

Context 'An error occurs retrieving WSUS Server configuration information.' {
Mock -CommandName Get-WsusServer -MockWith { throw 'An error occurred.' }
Expand Down

0 comments on commit b6f9e32

Please sign in to comment.