-
Notifications
You must be signed in to change notification settings - Fork 81
Update Pester to 6.0.0 #467
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
base: main
Are you sure you want to change the base?
Changes from all commits
47f3bf2
e72fa74
9441eec
cbf71c8
ef5c7c2
d268b1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,7 +113,7 @@ Describe "DSC_SystemRestorePoint\Get-TargetResource" -Tag 'Get' { | |
| $protectionSettings = Get-TargetResource -Ensure 'Present' -Description 'DSC Unit Test' | ||
|
|
||
| $protectionSettings.Ensure | Should -Be 'Absent' | ||
| Assert-MockCalled -CommandName Write-Warning -Times 1 | ||
| Should -Invoke -CommandName Write-Warning -Times 1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π Major | β‘ Quick win Add Same issue as As per coding guidelines, use π‘οΈ Proposed fix for all changed `Should -Invoke` calls # Line 116
- Should -Invoke -CommandName Write-Warning -Times 1
+ Should -Invoke -CommandName Write-Warning -Exactly -Times 1 -Scope It
# Line 204
- Should -Invoke -CommandName Write-Warning -Times 2
+ Should -Invoke -CommandName Write-Warning -Exactly -Times 2 -Scope ItAlso applies to: 204-204 π€ Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
| } | ||
| } | ||
|
|
@@ -201,7 +201,7 @@ Describe "DSC_SystemRestorePoint\Test-TargetResource" -Tag 'Test' { | |
| $desiredState = Test-TargetResource -Ensure 'Present' -Description 'DSC Unit Test' | ||
|
|
||
| $desiredState | Should -BeTrue | ||
| Assert-MockCalled -CommandName Write-Warning -Times 2 | ||
| Should -Invoke -CommandName Write-Warning -Times 2 | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π― Functional Correctness | π Major | β‘ Quick win
Add
-Exactlyand-Scope Itto allShould -Invokeassertions.Per the test guidelines, call-count assertions must use
Should -Invoke -Exactly -Times <n> -Scope It. All migratedShould -Invokecalls in this file are missing both-Exactlyand-Scope It. Without-Exactly,-Times 1asserts "at least 1" rather than "exactly 1". Without-Scope It, mock calls may be counted across the entireContextorDescribeinstead of just the currentItblock β particularly impactful inContext 'When configuration is required'(line 351) which contains multipleItblocks. This is also inconsistent with the already-migratedShould -Invokecalls inDSC_Computer.Tests.ps1(e.g., lines 789β790) which use-Exactly -Times 0 -Scope It.As per coding guidelines, use
Should -Invoke -Exactly -Times <n> -Scope Itfor call-count assertions, and assert<n>calls inside theItblock; do not assert call counts across an entireDescribeorContext.π‘οΈ Proposed fix for all changed `Should -Invoke` calls
Also applies to: 266-266, 360-360, 372-372, 385-386, 428-431
π€ Prompt for AI Agents
Source: Coding guidelines