-
Notifications
You must be signed in to change notification settings - Fork 8.1k
WIP: Use new Pester syntax: -Parameter for Modules/Microsoft.PowerShell.LocalAccounts tests #6499
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I remove the if/else and just $result | Should -Not -BeNullOrEmpty instead
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.
No.
|
|
||
| $finalCount = (Get-LocalGroup).Count | ||
| $initialCount -eq $finalCount + 1 | Should Be true | ||
| $initialCount | Should -Be ($finalCount + 1) |
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.
Is this an appropriate refactor to add to this pull request?
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.
Yes.
|
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-match -> -MatchExactly
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be $expectedFqeid | ||
| {& $sb} | Should -Throw -ErrorId $expectedFqeid |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-MatchExactly for strings for all commits.
| } | ||
| catch { | ||
| $_.FullyQualifiedErrorId | Should Be $expectedFqeid | ||
| {& $sb} | Should -Throw -ErrorId $expectedFqeid |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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