These commits update the tests to be compatible with Pester 5, as well as making some small maintenance commits to correct issues raised by the tests, e.g. trailing whitespace, unused parameters, etc. No tests were removed.
Related Issue
Fixes #148
Motivation and Context
This will allow us to use Pester 5 going forward. It should also result in easier addressing of PSSA test failures, as the new method (thanks to Jaykul) gives explicit failures with filepaths and line numbers.
How Has This Been Tested?
Primary testing was performed on a clean docker image running mcr.microsoft.com/powershell, without Chocolatey installed.
Tests were also run on a Windows 10 machine, with Chocolatey installed, and are passing on AppVeyor.
The tests now work with Chocolatey there or not, and other than the xDscResource tests work without elevation. This should be great for future users wanting to add to the tests!
Screenshots (if appropriate):
Example of old PSSA failures, taken from another PR:
[-] passes the PSScriptAnalyzer Rule PSShouldProcess 986ms
Expected 0, but got 1.
[-] passes the PSScriptAnalyzer Rule PSShouldProcess 986ms
Expected 0, but got 1.
34: (Invoke-ScriptAnalyzer -Path $module.FullName -IncludeRule $rule.RuleName ).Count | Should Be 0
at , C:\projects\cchoco\tests\cChoco_ScriptAnalyzerTests.ps1: line 3434: (Invoke-ScriptAnalyzer -Path $module.FullName -IncludeRule $rule.RuleName ).Count | Should Be 0
at , C:\projects\cchoco\tests\cChoco_ScriptAnalyzerTests.ps1: line 34
Example of new PSSA failures:
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
[~] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
[ ] I have updated the documentation accordingly.
[~] I have read the CONTRIBUTING document.
[ ] I have added tests to cover my changes.
[x] All new and existing tests passed.
Notes: There's no current contributing document that I can see. I also think I've changed the code style of the tests a little, but I think this is in the spirit of the issue.
Description
These commits update the tests to be compatible with Pester 5, as well as making some small maintenance commits to correct issues raised by the tests, e.g. trailing whitespace, unused parameters, etc. No tests were removed.
Related Issue
Fixes #148
Motivation and Context
This will allow us to use Pester 5 going forward. It should also result in easier addressing of PSSA test failures, as the new method (thanks to Jaykul) gives explicit failures with filepaths and line numbers.
How Has This Been Tested?
Primary testing was performed on a clean docker image running
mcr.microsoft.com/powershell
, without Chocolatey installed. Tests were also run on a Windows 10 machine, with Chocolatey installed, and are passing on AppVeyor. The tests now work with Chocolatey there or not, and other than the xDscResource tests work without elevation. This should be great for future users wanting to add to the tests!Screenshots (if appropriate):
Example of old PSSA failures, taken from another PR:
Example of new PSSA failures:
Types of changes
Checklist:
Notes: There's no current contributing document that I can see. I also think I've changed the code style of the tests a little, but I think this is in the spirit of the issue.