WIP: Use new Pester syntax: -Parameter for Modules/Microsoft.PowerShell.LocalAccounts tests#6499
Conversation
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be $expectedFqeid | ||
| {& $sb} | Should -Throw -ErrorId $expectedFqeid |
There was a problem hiding this comment.
I'm not sure if this is the best way to refactor this with the use of try/finally here to toggle ErrorActionPreference. There is a hand full of instances of this pattern in this file
There was a problem hiding this comment.
I believe we could do:
{
$script:ErrorActionPreference = "Stop"
try {
& $sb
} finally {
$script:ErrorActionPreference = $backupEAP
}
} Should -Throw -ErrorId $expectedFqeid | { | ||
| # Force failing the test because an unexpected outcome occurred | ||
| $false | Should Be $true | ||
| $false | Should -BeTrue |
There was a problem hiding this comment.
Can I remove the if/else and just $result | Should -Not -BeNullOrEmpty instead
|
|
||
| $finalCount = (Get-LocalGroup).Count | ||
| $initialCount -eq $finalCount + 1 | Should Be true | ||
| $initialCount | Should -Be ($finalCount + 1) |
There was a problem hiding this comment.
Is this an appropriate refactor to add to this pull request?
|
@iSazonov I have a few questions on this PR that I called out in the code before someone does a full review. Overal, there was a lot of left side logic that was piping to |
| $result[2] -match "TestGroupGet1" | Should Be true | ||
| $result[0] | Should -Be 1 | ||
| $result[1] | Should -Match "GroupNotFound" | ||
| $result[2] | Should -match "TestGroupGet1" |
There was a problem hiding this comment.
-match -> -MatchExactly
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be $expectedFqeid | ||
| {& $sb} | Should -Throw -ErrorId $expectedFqeid |
There was a problem hiding this comment.
The same pattern as above.
| $result[0].Name -match ($OptDomainPrefix + "TestUser1") | Should Be $true | ||
| $result[1].Name -match ($OptDomainPrefix + "TestUser2") | Should Be $true | ||
| $result[0].Name | Should -Match ($OptDomainPrefix + "TestUser1") | ||
| $result[1].Name | Should -Match ($OptDomainPrefix + "TestUser2") |
There was a problem hiding this comment.
-MatchExactly for strings for all commits.
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be $expectedFqeid | ||
| {& $sb} | Should -Throw -ErrorId $expectedFqeid |
There was a problem hiding this comment.
The same pattern as above
|
@adityapatwardhan Do we even run |
|
@daxian-dbw Yes, you are correct, we do not run these tests anymore. |
|
@KevinMarquette I appreciate you taking the time to clean up these tests, however, to validate the changes are correct, you'll need to run them on Windows PowerShell 5.1 where the LocalAccounts module still exists. These tests all have a |
|
I was relying on the CI triggers for the build. I didn't even notice the |
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
|
Up. |
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be "ParameterArgumentValidationError,Microsoft.PowerShell.Commands.NewLocalGroupCommand" | ||
| {$shouldBeNull = New-LocalGroup -Name $name -Description $desc} | |
There was a problem hiding this comment.
NIT: whitespace after opening brace and before closing brace
|
This PR has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed if no further activity occurs within 10 days. |
|
This PR has be automatically close because it is stale. If you wish to continue working on the PR, please first update the PR, then reopen it. |
PR Summary
Use new Pester syntax: -Parameter for Pester in Modules/Microsoft.PowerShell.LocalAccounts
Resolves part of #6245
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests