Skip to content

Commit 62ba944

Browse files
authored
Migrate to Pester 5 (#434)
1 parent fb177d6 commit 62ba944

File tree

56 files changed

+15364
-11729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+15364
-11729
lines changed

.vscode/settings.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@
5555
"pester.pesterModulePath": "./output/RequiredModules/Pester",
5656
"powershell.pester.codeLens": true,
5757
"pester.suppressCodeLensNotice": true,
58+
"yaml.format.singleQuote": true,
5859
}

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55

66
## [Unreleased]
77

8+
### Fixed
9+
10+
- `VirtualMemory` fix incorrect variable name
11+
- `SmbServerConfiguration` remove errant argument
12+
13+
### Changed
14+
15+
- Converted tests to Pester 5
16+
- Rename Delete-ADSIObject to Delete-ADSIObject to satisfy HQRM
17+
18+
### Removed
19+
20+
- Removed `Get-InvalidOperationRecord` to use version provided by `DscResource.Test`
21+
822
## [9.2.0] - 2024-09-30
923

1024
### Added

RequiredModules.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
InvokeBuild = 'latest'
1111
PSScriptAnalyzer = 'latest'
12-
Pester = '4.10.1'
12+
Pester = 'latest'
1313
Plaster = 'latest'
1414
ModuleBuilder = 'latest'
1515
ChangelogManagement = 'latest'

build.yaml

+28-25
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ BuildWorkflow:
2626
- package_module_nupkg
2727

2828
hqrmtest:
29-
- DscResource_Tests_Stop_On_Fail
29+
- Invoke_HQRM_Tests_Stop_On_Fail
3030

3131
test:
3232
- Pester_Tests_Stop_On_Fail
33+
- Convert_Pester_Coverage
3334
- Pester_If_Code_Coverage_Under_Threshold
3435

3536
publish:
36-
- publish_module_to_gallery
3737
- Publish_Release_To_GitHub
38+
- Publish_Module_To_gallery
3839
- Publish_GitHub_Wiki_Content
39-
- Create_ChangeLog_GitHub_PR
4040

4141
####################################################
4242
# ModuleBuilder Configuration #
@@ -91,16 +91,6 @@ NestedModule:
9191
# Pester Configuration (Sampler) #
9292
####################################################
9393
Pester:
94-
# Pester 4 configuration
95-
Script:
96-
- tests/Unit
97-
ExcludeTag:
98-
Tag:
99-
CodeCoverageOutputFile: JaCoCo_coverage.xml
100-
CodeCoverageOutputFileEncoding: ascii
101-
CodeCoverageThreshold: 80
102-
103-
# Pester 5 configuration
10494
Configuration:
10595
Run:
10696
Path:
@@ -110,7 +100,7 @@ Pester:
110100
StackTraceVerbosity: Full
111101
CIFormat: Auto
112102
CodeCoverage:
113-
CoveragePercentTarget: 80
103+
CoveragePercentTarget: 85
114104
OutputPath: JaCoCo_coverage.xml
115105
OutputEncoding: ascii
116106
UseBreakpoints: false
@@ -125,15 +115,28 @@ Pester:
125115
# Pester Configuration (DscResource.Test) #
126116
####################################################
127117
DscTest:
128-
OutputFormat: NUnitXML
129-
ExcludeTag:
130-
- 'Common Tests - New Error-Level Script Analyzer Rules'
131-
ExcludeSourceFile:
132-
- output
133-
ExcludeModuleFile:
134-
- Modules/DscResource.Common
135-
- Modules/DscResource.Base
136-
MainGitBranch: main
118+
Pester:
119+
Configuration:
120+
Filter:
121+
ExcludeTag:
122+
- "Common Tests - New Error-Level Script Analyzer Rules"
123+
Output:
124+
Verbosity: Detailed
125+
CIFormat: Auto
126+
TestResult:
127+
Enabled: true
128+
OutputFormat: NUnitXML
129+
OutputEncoding: ascii
130+
OutputPath: ./output/testResults/NUnitXml_HQRM_Tests.xml
131+
Script:
132+
ExcludeSourceFile:
133+
- output
134+
ExcludeModuleFile:
135+
- Modules/DscResource.Common
136+
- Modules/DscResource.Base
137+
# Must exclude built module file because it should not be tested like MOF-based resources
138+
- ComputerManagementDsc.psm1
139+
MainGitBranch: main
137140

138141
####################################################
139142
# PSDepend Configuration #
@@ -180,5 +183,5 @@ DscResource.DocGenerator:
180183
Type: CompositeResource
181184
Category: Resources
182185
Generate_Wiki_Sidebar:
183-
Debug: false
184-
AlwaysOverwrite: true
186+
Debug: false
187+
AlwaysOverwrite: true

source/DSCResources/DSC_Computer/DSC_Computer.psm1

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope = 'Function')]
2-
param
3-
(
4-
)
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'DSCMachineStatus', Justification = 'GlobalDsc Variable can be ignored')]
3+
param ()
54

65
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
76

@@ -268,7 +267,7 @@ function Set-TargetResource
268267

269268
if ($computerObject)
270269
{
271-
Delete-ADSIObject -Path $computerObject.Path -Credential $Credential
270+
Remove-ADSIObject -Path $computerObject.Path -Credential $Credential
272271
Write-Verbose -Message ($script:localizedData.DeletedExistingComputerObject -f $Name, $computerObject.Path)
273272
}
274273

@@ -755,7 +754,7 @@ function Get-ADSIComputer
755754
.PARAMETER Credential
756755
Credential to authenticate to the domain.
757756
#>
758-
function Delete-ADSIObject
757+
function Remove-ADSIObject
759758
{
760759
[CmdletBinding()]
761760
param
@@ -877,5 +876,3 @@ function Assert-ResourceProperty
877876
-ArgumentName 'Credential'
878877
}
879878
}
880-
881-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_IEEnhancedSecurityConfiguration/DSC_IEEnhancedSecurityConfiguration.psm1

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope = 'Function')]
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'DSCMachineStatus', Justification = 'GlobalDsc Variable can be ignored')]
3+
param ()
4+
15
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
26

37
# Import the ComputerManagementDsc Common Modules

source/DSCResources/DSC_OfflineDomainJoin/DSC_OfflineDomainJoin.psm1

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "", Scope = "Function")]
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'DSCMachineStatus', Justification = 'GlobalDsc Variable can be ignored')]
23
param
34
(
45
)
@@ -239,5 +240,3 @@ function Get-DomainName
239240
$computerSystem.Domain
240241
}
241242
} # function Get-DomainName
242-
243-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_PendingReboot/DSC_PendingReboot.psm1

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidGlobalVars", "", Scope = "Function")]
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'DSCMachineStatus', Justification = 'GlobalDsc Variable can be ignored')]
23
param ()
34

45
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
@@ -383,5 +384,3 @@ function Get-PendingRebootState
383384

384385
return $pendingRebootState
385386
}
386-
387-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_PendingReboot/en-US/DSC_PendingReboot.data.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@{
1+
@{
22
RebootTriggers = @(
33
@{
44
Name = 'ComponentBasedServicing'

source/DSCResources/DSC_PowerPlan/DSC_PowerPlan.psm1

-2
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,3 @@ function Test-TargetResource
154154

155155
return $getTargetResourceResult.IsActive
156156
}
157-
158-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_PowerShellExecutionPolicy/DSC_PowerShellExecutionPolicy.psm1

-2
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,3 @@ function Test-TargetResource
134134
return $false
135135
}
136136
}
137-
138-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_RemoteDesktopAdmin/DSC_RemoteDesktopAdmin.psm1

-2
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,3 @@ function Set-TargetResource
180180
Set-ItemProperty -Path $script:winStationsRegistryKey -Name "UserAuthentication" -Value $UserAuthenticationRegistry
181181
}
182182
}
183-
184-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_ScheduledTask/DSC_ScheduledTask.psm1

+4-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ function Set-TargetResource
545545

546546
$action = New-ScheduledTaskAction @actionParameters
547547

548-
$scheduledTaskArguments += @{
548+
$scheduledTaskArguments = @{
549549
Action = $action
550550
}
551551

@@ -715,6 +715,9 @@ function Set-TargetResource
715715
-ErrorRecord $_
716716
}
717717

718+
# Add to please strict mode
719+
$repetition = $null
720+
718721
if ($RepeatInterval -gt [System.TimeSpan]::Parse('0:0:0'))
719722
{
720723
# A repetition pattern is required so create it and attach it to the trigger object

source/DSCResources/DSC_SmbServerConfiguration/DSC_SmbServerConfiguration.psm1

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function Get-TargetResource
3535
$IsSingleInstance
3636
)
3737

38-
Write-Verbose -Message ($script:localizedData.GetTargetResourceMessage -f $Name)
38+
Write-Verbose -Message ($script:localizedData.GetTargetResourceMessage)
3939

4040
$smbReturn = @{}
4141
$smbServer = Get-SmbServerConfiguration -ErrorAction 'SilentlyContinue'
@@ -704,5 +704,3 @@ function Test-TargetResource
704704

705705
return $resourceCompliant
706706
}
707-
708-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_SystemLocale/DSC_SystemLocale.psm1

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Scope = 'Function')]
2+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', 'DSCMachineStatus', Justification = 'GlobalDsc Variable can be ignored')]
3+
param ()
4+
15
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
26

37
# Import the ComputerManagementDsc Common Modules
@@ -187,5 +191,3 @@ function Test-SystemLocaleValue
187191

188192
return ($SystemLocale -in $validCultures)
189193
}
190-
191-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_TimeZone/DSC_TimeZone.psm1

-2
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,3 @@ function Test-TargetResource
121121

122122
return Test-TimeZoneId -TimeZoneId $TimeZone
123123
}
124-
125-
Export-ModuleMember -Function *-TargetResource

0 commit comments

Comments
 (0)