Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Pester 5 #532

Open
wants to merge 122 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
3b8fcbe
Prepare module for Pester 5
dan-hughes Nov 23, 2024
bfd2559
Remove function provided by DscResource.Test
dan-hughes Nov 23, 2024
a402179
Update DefaultGatewayAddress
dan-hughes Nov 23, 2024
f720329
UPdate DSC_DnsClientGlobalSetting
dan-hughes Nov 23, 2024
ec6f608
Remove .Common module
dan-hughes Nov 23, 2024
59d6f5a
Move private functions back to resource
dan-hughes Nov 24, 2024
7c7ec1b
Unpack .Common module to private/public
dan-hughes Nov 24, 2024
f504d8f
Update DefaultGateway Integration Test
dan-hughes Nov 24, 2024
1ccfa39
Do not copy modules directory
dan-hughes Nov 24, 2024
705b721
Update Integration tests
dan-hughes Nov 24, 2024
7e9bdee
Update friendlyname
dan-hughes Nov 24, 2024
e6555e2
Re-add export-modulemember
dan-hughes Nov 24, 2024
24e4481
Remove .Common module import
dan-hughes Nov 24, 2024
516bdc8
Move .common functions to public
dan-hughes Nov 24, 2024
ae94442
Add cspell words
dan-hughes Nov 24, 2024
4626a18
Update integration tests
dan-hughes Nov 24, 2024
2c63258
Update integration tests
dan-hughes Nov 24, 2024
598e454
Disable export on commontesthelper
dan-hughes Nov 24, 2024
9149bd7
Update whitespace
dan-hughes Nov 24, 2024
abe06c8
Update tests
dan-hughes Nov 24, 2024
fae416c
Update whitespace
dan-hughes Nov 24, 2024
295092b
Update config file path
dan-hughes Nov 24, 2024
b51bebd
Update integration tests
dan-hughes Nov 24, 2024
a4dd90e
Update integration tests
dan-hughes Nov 24, 2024
5196654
Move adapter creation and cleanup to main describe
dan-hughes Nov 24, 2024
4ffcc6d
Update tests
dan-hughes Nov 24, 2024
731ba31
Update integration tests
dan-hughes Nov 24, 2024
6e0ed0a
Disable remaining integration tests
dan-hughes Nov 24, 2024
cdf25dc
Move stub to parent beforeall
dan-hughes Nov 24, 2024
6177864
Disable test
dan-hughes Nov 24, 2024
78fbbfa
Update before/afterall order
Nov 26, 2024
7e58662
Disable all but one integration tests
Nov 26, 2024
c06e376
Enable DNSConnectionSuffix Int test
Nov 26, 2024
3924e78
Enable DnsServerAddress int test
Nov 26, 2024
2fd385a
Add Wait-ForIdleLcm to help test failures
Nov 26, 2024
029ca2b
Remove reference to NetworkingDsc.Common.psm1
Nov 26, 2024
4472a88
Enable HostsFile Int tests
Nov 26, 2024
c888d5c
Enable IPAddress int test
Nov 26, 2024
a2454be
Enable IPAddressOption int test
Nov 26, 2024
ae24301
Enable Netadapterbinding int test
Nov 26, 2024
84f5dc4
Enable NetadapterLso int test
Nov 26, 2024
60be425
Enable netadaptername int test
Nov 26, 2024
520a4b7
Enable NetAdapterRdma int tests
Nov 26, 2024
d055da2
Update variables
Nov 26, 2024
c5fe025
Enable NetAdapterState int tests
Nov 26, 2024
1b79b10
Enable netbios int tests
Nov 26, 2024
8174b34
Fix HQRM errors
Nov 26, 2024
c03eecc
Add changelog
Nov 26, 2024
dcebb4c
Update netbios int tests
Nov 26, 2024
0df5fea
Enable netconnectionprofile int tests
Nov 26, 2024
6dd769b
Add wait
Nov 26, 2024
a028ad4
enable netipinterface int tests
Nov 26, 2024
c28c7cf
Enable networkteam int tests
Nov 26, 2024
a5f806b
Enable networkteaminterface int tests
Nov 26, 2024
fdc7dd0
Enable proxysettings int tests
Nov 26, 2024
faadd1c
Add import to allow discovery to run
Nov 26, 2024
b2ef134
Add Route int tests
Nov 26, 2024
7362741
Enable WaitForNetworkTeam
Nov 26, 2024
ec76b5b
Enable WinsServerAddress int tests
Nov 26, 2024
7b17606
Enable WinsSetting int tests
Nov 26, 2024
35f3cf2
Enable DnsClientGlobalSetting
Nov 26, 2024
af48a32
Add Wait-ForIdleLcm
Nov 26, 2024
9c35fec
Enable Firewall int test
Nov 26, 2024
f22093c
Disable tests not migrated
Nov 26, 2024
a0e3bc0
Move Convert-CIDRToSubnetMask to public
Nov 26, 2024
03835aa
Update tests
Nov 27, 2024
6821197
Update logic order
Nov 27, 2024
467b99e
Enable FirewallProfile int tests
Nov 27, 2024
b3f1183
Convert DnsConnectionSuffix
Nov 27, 2024
c876470
Remove commented code
Nov 27, 2024
fc7f796
Convert more tests
Nov 27, 2024
8a1ed85
Fix double set parameter
Nov 27, 2024
2e740cb
Covmert HostsFile fix bug in module
Nov 28, 2024
9b48d7e
Remove verbose
Nov 28, 2024
464f855
Migrate IPAddress tests
Nov 28, 2024
7aa5125
Update IPAddressOption
Nov 28, 2024
7ef1564
Update NetAdapterAdvProp tests
Nov 28, 2024
6c83dc0
Update WinsServerAddress
Nov 28, 2024
b897fa8
Convert WaitForNetworkTeam
Nov 28, 2024
f9d2d78
Update Route tests
Nov 28, 2024
28c368f
Update ProxySettings
Nov 28, 2024
003a953
Update netconnectionprofile
Nov 28, 2024
8905130
Add common words to ignore
Nov 28, 2024
19309bb
Remove extra parameters
Nov 28, 2024
7b9a8ea
Update NetworkTeamInterface
dan-hughes Nov 30, 2024
0c4aa66
Update NetAdapterBinding
dan-hughes Nov 30, 2024
27d113f
Update NetAdapterLso
dan-hughes Nov 30, 2024
233a9ec
Migrate NetAdapterName
dan-hughes Nov 30, 2024
6a592bb
Fix error
dan-hughes Nov 30, 2024
e955326
Update filename
dan-hughes Nov 30, 2024
7f95b01
Add rdma to spelling
dan-hughes Dec 1, 2024
5213b77
Update NetAdapterRdma
dan-hughes Dec 1, 2024
5ffac85
Update NetAdapterRsc
dan-hughes Dec 1, 2024
bfa641e
Update NetAdapterRss
dan-hughes Dec 1, 2024
5005044
Update NetAdapterState
dan-hughes Dec 1, 2024
d556793
Fix strictmode errors
dan-hughes Dec 1, 2024
399a8c9
Update NetIPInterface
dan-hughes Dec 1, 2024
1241464
Update NetworkTeam
dan-hughes Dec 1, 2024
d50367d
Fix strictmode error
dan-hughes Dec 1, 2024
6f30ced
Import NetTCPIP in beforediscovery
dan-hughes Dec 1, 2024
3b8b3a4
Fix intermittent test failures
dan-hughes Dec 1, 2024
10412a0
Add netbios to valid words
dan-hughes Dec 22, 2024
e2a3d2c
Migrate netbios tests
dan-hughes Dec 22, 2024
afa0503
Remove commented code
dan-hughes Dec 23, 2024
f219c18
Update module file path
dan-hughes Jan 3, 2025
af356fd
Update indent
dan-hughes Jan 3, 2025
79083ee
Fix typo
dan-hughes Jan 3, 2025
4903292
Migrate FirewallProfile
dan-hughes Jan 4, 2025
feb116c
Fix typo in function name
dan-hughes Jan 4, 2025
ceaa7f7
Migrate Firewall tests part 1
dan-hughes Jan 4, 2025
d573580
Remove commented setup code
dan-hughes Jan 4, 2025
5ab1ce9
Use test generation
dan-hughes Jan 5, 2025
b7c0c82
Fix variable name
dan-hughes Jan 5, 2025
7f8beac
Firewall tests part 2
dan-hughes Jan 5, 2025
ab7de4d
Remove DisplayGroup parameter from new rule creation
dan-hughes Jan 5, 2025
138ee7c
Use non alias function name
dan-hughes Jan 5, 2025
a629299
Update changelog
dan-hughes Jan 5, 2025
be7ba0c
Remove commented code
dan-hughes Jan 5, 2025
ff1b8f7
Remove Pesterv4 test function
dan-hughes Jan 5, 2025
977ecea
Remove commented code
dan-hughes Jan 5, 2025
1bcfc08
Re-enable Export-ModuleMember
dan-hughes Jan 12, 2025
88712ed
Update formatting
dan-hughes Jan 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@
"keepachangelog",
"notin",
"pscmdlet",
"steppable"
"steppable",
"contoso",
"fabrikam",
"fourthcoffee",
"Lbfo",
"HKLM",
"HKCU",
"RDMA",
"Netbios"
],
"cSpell.ignorePaths": [
".git"
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated pipeline files to match current DSC Community patterns - fixes [Issue #528](https://github.com/dsccommunity/NetworkingDsc/issues/528).
- Updated HQRM and build steps to use windows-latest image.
- Update build pieline to pin GitVersion v5.
- Tests
- Update to use Pester 5.
- `New-InvalidArgumentException` change to `New-ArgumentException` for HQRM.

### Fixed

- `DSC_Firewall`
- Fixed comment typo.
- Fixed `ParameterList` in `Set-TargetResource` typo.
- Remove `DisplayGroup` property when creating new firewall rule.
- `Test-RuleProperties`
- Fixed `Convert-CIDRToSubnetMask` function call typo.
-

### Removed

- `NetworkingDsc.Common`
- Functions moved to separate files in Public directory.
- Each resource removed import at top of file.
- `Build.psd1`
- Removed as not required.
- `DSC_IPAddress`
- Remove IPv6 prefix length as unused.

## [9.0.0] - 2022-05-30

Expand Down
26 changes: 13 additions & 13 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
@{
PSDependOptions = @{
PSDependOptions = @{
AddToPath = $true
Target = 'output\RequiredModules'
Parameters = @{
Repository = ''
}
}

InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = '4.10.1'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Test' = 'latest'
xDscResourceDesigner = 'latest'
LoopbackAdapter = 'latest'
InvokeBuild = 'latest'
PSScriptAnalyzer = 'latest'
Pester = 'latest'
Plaster = 'latest'
ModuleBuilder = 'latest'
ChangelogManagement = 'latest'
Sampler = 'latest'
'Sampler.GitHubTasks' = 'latest'
MarkdownLinkCheck = 'latest'
'DscResource.Test' = 'latest'
xDscResourceDesigner = 'latest'
LoopbackAdapter = 'latest'

# Build dependencies needed for using the module
'DscResource.Common' = 'latest'
Expand Down
51 changes: 25 additions & 26 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,26 @@ BuildWorkflow:
- package_module_nupkg

hqrmtest:
- DscResource_Tests_Stop_On_Fail
- Invoke_HQRM_Tests_Stop_On_Fail

test:
- Pester_Tests_Stop_On_Fail
- Convert_Pester_Coverage
- Pester_If_Code_Coverage_Under_Threshold

publish:
- publish_module_to_gallery
- Publish_Release_To_GitHub
- Publish_GitHub_Wiki_Content
- Create_ChangeLog_GitHub_PR

####################################################
# ModuleBuilder Configuration #
####################################################
CopyPaths:
- en-US
- DSCResources
- Modules
Prefix: prefix.ps1
Suffix: suffix.ps1
Encoding: UTF8
VersionedOutputDirectory: true
BuiltModuleSubdirectory: builtModule

ModuleBuildTasks:
Expand Down Expand Up @@ -87,16 +84,6 @@ NestedModule:
####################################################

Pester:
# Pester 4 configuration
Script:
- tests/Unit
ExcludeTag:
Tag:
CodeCoverageOutputFile: JaCoCo_coverage.xml
CodeCoverageOutputFileEncoding: ascii
CodeCoverageThreshold: 80

# Pester 5 configuration
Configuration:
Run:
Path:
Expand All @@ -120,14 +107,26 @@ Pester:
# Pester Configuration (DscResource.Test) #
####################################################
DscTest:
OutputFormat: NUnitXML
ExcludeTag:
- 'Common Tests - New Error-Level Script Analyzer Rules'
ExcludeSourceFile:
- output
ExcludeModuleFile:
- Modules/DscResource.Common
MainGitBranch: main
Pester:
Configuration:
Filter:
ExcludeTag:
- 'Common Tests - New Error-Level Script Analyzer Rules'
Output:
Verbosity: Detailed
CIFormat: Auto
TestResult:
Enabled: true
OutputFormat: NUnitXML
OutputEncoding: ascii
OutputPath: ./output/testResults/NUnitXml_HQRM_Tests.xml
Script:
ExcludeSourceFile:
- output
ExcludeModuleFile:
- Modules/DscResource.Common
- NetworkingDsc.psm1
MainGitBranch: main

####################################################
# PSDepend Configuration #
Expand Down Expand Up @@ -163,7 +162,7 @@ DscResource.DocGenerator:
- '\*(.+?)\*' # Match Italic (asterisk)
Publish_GitHub_Wiki_Content:
Debug: false
Generate_Wiki_Content:
Generate_Markdown_For_DSC_Resources:
MofResourceMetadata:
Type: MofResource
Category: Resources
Expand All @@ -174,5 +173,5 @@ DscResource.DocGenerator:
Type: CompositeResource
Category: Resources
Generate_Wiki_Sidebar:
Debug: false
AlwaysOverwrite: true
Debug: false
AlwaysOverwrite: true
5 changes: 0 additions & 5 deletions source/Build.psd1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'

# Import the Networking Common Modules
Import-Module -Name (Join-Path -Path $modulePath `
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
-ChildPath 'NetworkingDsc.Common.psm1'))

Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')

# Import Localization Strings
Expand Down Expand Up @@ -48,9 +43,6 @@ function Get-TargetResource
$($script:localizedData.GettingDefaultGatewayAddressMessage)
) -join '' )

$destinationPrefix = Get-NetDefaultGatewayDestinationPrefix `
-AddressFamily $AddressFamily

$defaultRoutes = Get-NetDefaultRoute `
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily
Expand Down Expand Up @@ -118,8 +110,8 @@ function Set-TargetResource
) -join '' )

$defaultRoutes = @(Get-NetDefaultRoute `
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily)
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily)

# Remove any existing default routes
foreach ($defaultRoute in $defaultRoutes)
Expand Down Expand Up @@ -203,17 +195,17 @@ function Test-TargetResource
Assert-ResourceProperty @PSBoundParameters

$defaultRoutes = @(Get-NetDefaultRoute `
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily)
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily)

# Test if the Default Gateway passed is equal to the current default gateway
if ($Address)
{
if ($defaultRoutes)
{
$nextHopRoute = $defaultRoutes.Where( {
$_.NextHop -eq $Address
} )
$_.NextHop -eq $Address
} )

if ($nextHopRoute)
{
Expand Down Expand Up @@ -302,7 +294,7 @@ function Assert-ResourceProperty
{
Assert-IPAddress -Address $Address -AddressFamily $AddressFamily
}
} # Assert-ResourceProperty
}

<#
.SYNOPSIS
Expand Down Expand Up @@ -333,7 +325,7 @@ function Get-NetDefaultGatewayDestinationPrefix
}

return $destinationPrefix
} # Get-NetDefaultGatewayDestinationPrefix
}

<#
.SYNOPSIS
Expand Down Expand Up @@ -366,11 +358,9 @@ function Get-NetDefaultRoute
-AddressFamily $AddressFamily

return @(Get-NetRoute `
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily `
-ErrorAction Stop).Where({
-InterfaceAlias $InterfaceAlias `
-AddressFamily $AddressFamily `
-ErrorAction Stop).Where({
$_.DestinationPrefix -eq $destinationPrefix
})
} # Get-NetDefaultRoute

Export-ModuleMember -function *-TargetResource
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'

# Import the Networking Common Modules
Import-Module -Name (Join-Path -Path $modulePath `
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
-ChildPath 'NetworkingDsc.Common.psm1'))

Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')

# Import Localization Strings
Expand Down Expand Up @@ -130,7 +125,7 @@ function Set-TargetResource
Write-Verbose -Message ( @(
"$($MyInvocation.MyCommand): "
$($script:localizedData.DnsClientGlobalSettingUpdateParameterMessage) `
-f $parameter.Name,($parameterNewValue -join ',')
-f $parameter.Name, ($parameterNewValue -join ',')
) -join '' )
} # if
} # foreach
Expand Down Expand Up @@ -263,5 +258,3 @@ function Test-TargetResource

return $desiredConfigurationMatch
} # Test-TargetResource

Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
$modulePath = Join-Path -Path (Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent) -ChildPath 'Modules'

# Import the Networking Common Modules
Import-Module -Name (Join-Path -Path $modulePath `
-ChildPath (Join-Path -Path 'NetworkingDsc.Common' `
-ChildPath 'NetworkingDsc.Common.psm1'))

Import-Module -Name (Join-Path -Path $modulePath -ChildPath 'DscResource.Common')

# Import Localization Strings
Expand Down Expand Up @@ -266,5 +261,3 @@ function Test-TargetResource

return $inDesiredState
}

Export-ModuleMember -function *-TargetResource
Loading
Loading