Skip to content

Commit c165bcc

Browse files
authored
Migrate to Pester 5 (#532)
1 parent d68f7af commit c165bcc

File tree

108 files changed

+20761
-12930
lines changed

Some content is hidden

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

108 files changed

+20761
-12930
lines changed

.vscode/settings.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@
3636
"keepachangelog",
3737
"notin",
3838
"pscmdlet",
39-
"steppable"
39+
"steppable",
40+
"contoso",
41+
"fabrikam",
42+
"fourthcoffee",
43+
"Lbfo",
44+
"HKLM",
45+
"HKCU",
46+
"RDMA",
47+
"Netbios",
48+
"HQRM"
4049
],
4150
"cSpell.ignorePaths": [
4251
".git"

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- CI Pipeline
1313
- Updated pipeline files to match current DSC Community patterns - fixes [Issue #528](https://github.com/dsccommunity/NetworkingDsc/issues/528).
1414
- Updated HQRM and build steps to use windows-latest image.
15-
- Update build pieline to pin GitVersion v5.
15+
- Update build pipeline to pin GitVersion v5.
16+
- Tests
17+
- Update to use Pester 5.
18+
- `New-InvalidArgumentException` change to `New-ArgumentException` for HQRM.
19+
- `NetworkingDsc.Common`
20+
- Changed to a buildable module.
21+
22+
### Fixed
23+
24+
- `DSC_Firewall`
25+
- Fixed comment typo.
26+
- Fixed `ParameterList` in `Set-TargetResource` typo.
27+
- Remove `DisplayGroup` property when creating new firewall rule.
28+
- `Test-RuleProperties`
29+
- Fixed `Convert-CIDRToSubnetMask` function call typo.
30+
-
31+
32+
### Removed
33+
34+
- `Build.psd1`
35+
- Removed as not required.
36+
- `DSC_IPAddress`
37+
- Remove IPv6 prefix length as unused.
38+
- `CommonTestHelper`
39+
- Use `Get-InvalidArgumentRecord` from `DscResource.Test`.
1640

1741
## [9.0.0] - 2022-05-30
1842

RequiredModules.psd1

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
@{
2-
PSDependOptions = @{
2+
PSDependOptions = @{
33
AddToPath = $true
44
Target = 'output\RequiredModules'
55
Parameters = @{
66
Repository = ''
77
}
88
}
99

10-
InvokeBuild = 'latest'
11-
PSScriptAnalyzer = 'latest'
12-
Pester = '4.10.1'
13-
Plaster = 'latest'
14-
ModuleBuilder = 'latest'
15-
ChangelogManagement = 'latest'
16-
Sampler = 'latest'
17-
'Sampler.GitHubTasks' = 'latest'
18-
MarkdownLinkCheck = 'latest'
19-
'DscResource.Test' = 'latest'
20-
xDscResourceDesigner = 'latest'
21-
LoopbackAdapter = 'latest'
10+
InvokeBuild = 'latest'
11+
PSScriptAnalyzer = 'latest'
12+
Pester = 'latest'
13+
Plaster = 'latest'
14+
ModuleBuilder = 'latest'
15+
ChangelogManagement = 'latest'
16+
Sampler = 'latest'
17+
'Sampler.GitHubTasks' = 'latest'
18+
MarkdownLinkCheck = 'latest'
19+
'DscResource.Test' = 'latest'
20+
xDscResourceDesigner = 'latest'
21+
LoopbackAdapter = 'latest'
2222

2323
# Build dependencies needed for using the module
2424
'DscResource.Common' = 'latest'

azure-pipelines.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
trigger:
22
branches:
33
include:
4-
- main
4+
- main
55
paths:
66
include:
7-
- source/*
7+
- source/*
88
tags:
99
include:
10-
- "v*"
10+
- 'v*'
1111
exclude:
12-
- "*-*"
12+
- '*-*'
1313

1414
variables:
1515
buildFolderName: output
@@ -105,7 +105,7 @@ stages:
105105
inputs:
106106
filePath: './build.ps1'
107107
arguments: "-Tasks test -PesterScript 'tests/Unit'"
108-
pwsh: false
108+
pwsh: true
109109

110110
- task: PublishTestResults@2
111111
displayName: 'Publish Test Results'
@@ -210,7 +210,7 @@ stages:
210210
inputs:
211211
filePath: './build.ps1'
212212
arguments: "-Tasks test -PesterScript 'tests/Unit'"
213-
pwsh: false
213+
pwsh: true
214214

215215
- task: PublishTestResults@2
216216
displayName: 'Publish Test Results'

build.yaml

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,25 @@ 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:
3637
- publish_module_to_gallery
3738
- Publish_Release_To_GitHub
3839
- Publish_GitHub_Wiki_Content
39-
- Create_ChangeLog_GitHub_PR
4040

4141
####################################################
4242
# ModuleBuilder Configuration #
4343
####################################################
4444
CopyPaths:
4545
- en-US
4646
- DSCResources
47-
- Modules
48-
Prefix: prefix.ps1
49-
Suffix: suffix.ps1
5047
Encoding: UTF8
51-
VersionedOutputDirectory: true
5248
BuiltModuleSubdirectory: builtModule
5349

5450
ModuleBuildTasks:
@@ -81,22 +77,20 @@ NestedModule:
8177
Path: ./output/RequiredModules/DscResource.Common
8278
AddToManifest: false
8379
Exclude: PSGetModuleInfo.xml
80+
NetworkingDsc.Common:
81+
Prefix: prefix.ps1
82+
VersionedOutputDirectory: false
83+
CopyPaths:
84+
- en-US
85+
Encoding: UTF8
86+
AddToManifest: false
87+
Exclude: PSGetModuleInfo.xml
8488

8589
####################################################
8690
# Pester Configuration (Sampler) #
8791
####################################################
8892

8993
Pester:
90-
# Pester 4 configuration
91-
Script:
92-
- tests/Unit
93-
ExcludeTag:
94-
Tag:
95-
CodeCoverageOutputFile: JaCoCo_coverage.xml
96-
CodeCoverageOutputFileEncoding: ascii
97-
CodeCoverageThreshold: 80
98-
99-
# Pester 5 configuration
10094
Configuration:
10195
Run:
10296
Path:
@@ -120,14 +114,26 @@ Pester:
120114
# Pester Configuration (DscResource.Test) #
121115
####################################################
122116
DscTest:
123-
OutputFormat: NUnitXML
124-
ExcludeTag:
125-
- 'Common Tests - New Error-Level Script Analyzer Rules'
126-
ExcludeSourceFile:
127-
- output
128-
ExcludeModuleFile:
129-
- Modules/DscResource.Common
130-
MainGitBranch: main
117+
Pester:
118+
Configuration:
119+
Filter:
120+
ExcludeTag:
121+
- 'Common Tests - New Error-Level Script Analyzer Rules'
122+
Output:
123+
Verbosity: Detailed
124+
CIFormat: Auto
125+
TestResult:
126+
Enabled: true
127+
OutputFormat: NUnitXML
128+
OutputEncoding: ascii
129+
OutputPath: ./output/testResults/NUnitXml_HQRM_Tests.xml
130+
Script:
131+
ExcludeSourceFile:
132+
- output
133+
ExcludeModuleFile:
134+
- Modules/DscResource.Common
135+
- NetworkingDsc.psm1
136+
MainGitBranch: main
131137

132138
####################################################
133139
# PSDepend Configuration #
@@ -163,7 +169,7 @@ DscResource.DocGenerator:
163169
- '\*(.+?)\*' # Match Italic (asterisk)
164170
Publish_GitHub_Wiki_Content:
165171
Debug: false
166-
Generate_Wiki_Content:
172+
Generate_Markdown_For_DSC_Resources:
167173
MofResourceMetadata:
168174
Type: MofResource
169175
Category: Resources
@@ -174,5 +180,5 @@ DscResource.DocGenerator:
174180
Type: CompositeResource
175181
Category: Resources
176182
Generate_Wiki_Sidebar:
177-
Debug: false
178-
AlwaysOverwrite: true
183+
Debug: false
184+
AlwaysOverwrite: true

source/Build.psd1

Lines changed: 0 additions & 5 deletions
This file was deleted.

source/DSCResources/DSC_DefaultGatewayAddress/DSC_DefaultGatewayAddress.psm1

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
22

33
# Import the Networking Common Modules
4-
Import-Module -Name (Join-Path -Path $modulePath `
5-
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
6-
-ChildPath 'NetworkingDsc.Common.psm1'))
7-
4+
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'NetworkingDsc.Common')
85
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')
96

107
# Import Localization Strings
@@ -48,9 +45,6 @@ function Get-TargetResource
4845
$($script:localizedData.GettingDefaultGatewayAddressMessage)
4946
) -join '' )
5047

51-
$destinationPrefix = Get-NetDefaultGatewayDestinationPrefix `
52-
-AddressFamily $AddressFamily
53-
5448
$defaultRoutes = Get-NetDefaultRoute `
5549
-InterfaceAlias $InterfaceAlias `
5650
-AddressFamily $AddressFamily
@@ -118,8 +112,8 @@ function Set-TargetResource
118112
) -join '' )
119113

120114
$defaultRoutes = @(Get-NetDefaultRoute `
121-
-InterfaceAlias $InterfaceAlias `
122-
-AddressFamily $AddressFamily)
115+
-InterfaceAlias $InterfaceAlias `
116+
-AddressFamily $AddressFamily)
123117

124118
# Remove any existing default routes
125119
foreach ($defaultRoute in $defaultRoutes)
@@ -203,17 +197,17 @@ function Test-TargetResource
203197
Assert-ResourceProperty @PSBoundParameters
204198

205199
$defaultRoutes = @(Get-NetDefaultRoute `
206-
-InterfaceAlias $InterfaceAlias `
207-
-AddressFamily $AddressFamily)
200+
-InterfaceAlias $InterfaceAlias `
201+
-AddressFamily $AddressFamily)
208202

209203
# Test if the Default Gateway passed is equal to the current default gateway
210204
if ($Address)
211205
{
212206
if ($defaultRoutes)
213207
{
214208
$nextHopRoute = $defaultRoutes.Where( {
215-
$_.NextHop -eq $Address
216-
} )
209+
$_.NextHop -eq $Address
210+
} )
217211

218212
if ($nextHopRoute)
219213
{
@@ -302,7 +296,7 @@ function Assert-ResourceProperty
302296
{
303297
Assert-IPAddress -Address $Address -AddressFamily $AddressFamily
304298
}
305-
} # Assert-ResourceProperty
299+
}
306300

307301
<#
308302
.SYNOPSIS
@@ -333,7 +327,7 @@ function Get-NetDefaultGatewayDestinationPrefix
333327
}
334328

335329
return $destinationPrefix
336-
} # Get-NetDefaultGatewayDestinationPrefix
330+
}
337331

338332
<#
339333
.SYNOPSIS
@@ -366,11 +360,9 @@ function Get-NetDefaultRoute
366360
-AddressFamily $AddressFamily
367361

368362
return @(Get-NetRoute `
369-
-InterfaceAlias $InterfaceAlias `
370-
-AddressFamily $AddressFamily `
371-
-ErrorAction Stop).Where({
363+
-InterfaceAlias $InterfaceAlias `
364+
-AddressFamily $AddressFamily `
365+
-ErrorAction Stop).Where({
372366
$_.DestinationPrefix -eq $destinationPrefix
373367
})
374-
} # Get-NetDefaultRoute
375-
376-
Export-ModuleMember -function *-TargetResource
368+
}

source/DSCResources/DSC_DnsClientGlobalSetting/DSC_DnsClientGlobalSetting.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
22

33
# Import the Networking Common Modules
4-
Import-Module -Name (Join-Path -Path $modulePath `
5-
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
6-
-ChildPath 'NetworkingDsc.Common.psm1'))
7-
4+
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'NetworkingDsc.Common')
85
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')
96

107
# Import Localization Strings
@@ -130,7 +127,7 @@ function Set-TargetResource
130127
Write-Verbose -Message ( @(
131128
"$($MyInvocation.MyCommand): "
132129
$($script:localizedData.DnsClientGlobalSettingUpdateParameterMessage) `
133-
-f $parameter.Name,($parameterNewValue -join ',')
130+
-f $parameter.Name, ($parameterNewValue -join ',')
134131
) -join '' )
135132
} # if
136133
} # foreach
@@ -263,5 +260,3 @@ function Test-TargetResource
263260

264261
return $desiredConfigurationMatch
265262
} # Test-TargetResource
266-
267-
Export-ModuleMember -Function *-TargetResource

source/DSCResources/DSC_DnsConnectionSuffix/DSC_DnsConnectionSuffix.psm1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'
22

33
# Import the Networking Common Modules
4-
Import-Module -Name (Join-Path -Path $modulePath `
5-
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
6-
-ChildPath 'NetworkingDsc.Common.psm1'))
7-
4+
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'NetworkingDsc.Common')
85
Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')
96

107
# Import Localization Strings
@@ -266,5 +263,3 @@ function Test-TargetResource
266263

267264
return $inDesiredState
268265
}
269-
270-
Export-ModuleMember -function *-TargetResource

0 commit comments

Comments
 (0)