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

Migrate to Pester 5 #532

wants to merge 122 commits into from

Conversation

dan-hughes
Copy link

@dan-hughes dan-hughes commented Nov 24, 2024

Pull Request (PR) description

Migrate all tests to Pester 5

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation added/updated in README.md.
  • Resource parameter descriptions added/updated in README.md, schema.mof
    and comment-based help.
  • Comment-based help added/updated.
  • Localization strings added/updated in all localization files as appropriate.
  • Examples appropriately added/updated.
  • Unit tests added/updated. See DSC Community Testing Guidelines.
  • Integration tests added/updated (where possible). See DSC Community Testing Guidelines.
  • New/changed code adheres to DSC Community Style Guidelines.

This change is Reviewable

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 29 of 29 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-hughes)


source/Private/Convert-CIDRToSubnetMask.ps1 line 9 at r1 (raw file):

        The array of addresses to that need to be converted.
#>
function Convert-CIDRToSubnetMask

If these are gonna be used in the MOF resources they need to be public functions, not private. Throughout where function is needed in MOF resource.

Code quote:

Convert-CIDRToSubnetMask

tests/TestHelpers/CommonTestHelper.psm1 line 210 at r1 (raw file):

    Test-NetworkTeamIntegrationEnvironment, `
    New-IntegrationLoopbackAdapter, `
    Remove-IntegrationLoopbackAdapter

Maybe here we should keep the export-modulemember since it says what to export even if there are more (private) functions in the module. 🤔

Code quote:

Export-ModuleMember -Function `
    Get-InvalidArgumentRecord, `
    Get-InvalidOperationRecord, `
    Test-NetworkTeamIntegrationEnvironment, `
    New-IntegrationLoopbackAdapter, `
    Remove-IntegrationLoopbackAdapter

@dan-hughes
Copy link
Author

Reviewed 29 of 29 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dan-hughes)

source/Private/Convert-CIDRToSubnetMask.ps1 line 9 at r1 (raw file):

        The array of addresses to that need to be converted.
#>
function Convert-CIDRToSubnetMask

If these are gonna be used in the MOF resources they need to be public functions, not private. Throughout where function is needed in MOF resource.

Code quote:

Convert-CIDRToSubnetMask

tests/TestHelpers/CommonTestHelper.psm1 line 210 at r1 (raw file):

    Test-NetworkTeamIntegrationEnvironment, `
    New-IntegrationLoopbackAdapter, `
    Remove-IntegrationLoopbackAdapter

Maybe here we should keep the export-modulemember since it says what to export even if there are more (private) functions in the module. 🤔

Code quote:

Export-ModuleMember -Function `
    Get-InvalidArgumentRecord, `
    Get-InvalidOperationRecord, `
    Test-NetworkTeamIntegrationEnvironment, `
    New-IntegrationLoopbackAdapter, `
    Remove-IntegrationLoopbackAdapter

Yeah, give me a minute. I wanted to check the build worked. I'm going to get all the integration tests up and running as there are HQRM fixes required 😊

@dan-hughes dan-hughes marked this pull request as draft November 24, 2024 16:37
@johlju
Copy link
Member

johlju commented Nov 24, 2024

No worries No hurry. I saw it was not draft so when I had a minute left I just browsed through it. 🙂

@dan-hughes
Copy link
Author

@johlju, do you have time to starting looking through this?

I have just the firewall and firewallprofile to finish off.

@johlju
Copy link
Member

johlju commented Jan 4, 2025

I have seen this but as it was still draft I didn’t do anything, but can look into that as well, probably after the ”WSMan” PR.

@dan-hughes
Copy link
Author

I didn't want to mark it as ready until I finished. The last tests were not Pester 5 friendly.

@dan-hughes dan-hughes marked this pull request as ready for review January 5, 2025 12:57
@dan-hughes
Copy link
Author

@johlju, ready to go.

Copy link
Member

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 24 of 45 files at r3, 55 of 66 files at r4, 4 of 4 files at r5, 1 of 2 files at r6, 11 of 11 files at r7, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dan-hughes)


tests/TestHelpers/CommonTestHelper.psm1 line 210 at r1 (raw file):

Previously, dan-hughes (Daniel Hughes) wrote…

Yeah, give me a minute. I wanted to check the build worked. I'm going to get all the integration tests up and running as there are HQRM fixes required 😊

Should we uncomment the Export-ModuleMember block now?


tests/Integration/DSC_NetAdapterName.Integration.Tests.ps1 line 198 at r7 (raw file):

                $_.ConfigurationName -eq "$($script:dscResourceName)_Config_NameOnly"
            }
            

Looks like there are blank spaces on this line, don't we have a VS Code project setting for automatically trimming white space at end of line on save? 🤔

Code quote:

···········

source/Public/Get-DnsClientServerStaticAddress.ps1 line 16 at r7 (raw file):

        IP address family.
#>
function Get-DnsClientServerStaticAddress

I wonder if we should prefix each public function (commented on another module as well). If there is another exported command with the same name it will be a conflict, so wonder if we should prefix all commands with NetDsc or something to make sure they are unique?

What do you think?

Code quote:

Get-DnsClientServerStaticAddress

@johlju johlju added the waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author. label Jan 12, 2025
Copy link
Author

@dan-hughes dan-hughes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 95 of 105 files reviewed, 2 unresolved discussions (waiting on @johlju)


tests/Integration/DSC_NetAdapterName.Integration.Tests.ps1 line 198 at r7 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

Looks like there are blank spaces on this line, don't we have a VS Code project setting for automatically trimming white space at end of line on save? 🤔

Fixed, not sure why vscode/PSSA was not picking this up. Checked all the integration test files.


source/Public/Get-DnsClientServerStaticAddress.ps1 line 16 at r7 (raw file):

Previously, johlju (Johan Ljunggren) wrote…

I wonder if we should prefix each public function (commented on another module as well). If there is another exported command with the same name it will be a conflict, so wonder if we should prefix all commands with NetDsc or something to make sure they are unique?

What do you think?

Valid point, but instead of a prefix maybe a suffix instead? Then searching for usages across repos may be easier as atleast the start of the function name matches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for code fix A review left open comments, and the pull request is waiting for changes to be pushed by the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intermittent Integration Test Failures on Windows Server 2022
2 participants