Fix pester tests syntax#11558
Conversation
|
@iSazonov PR is ready to merge, CodeFactor issues are not new. |
I don't think changes related to this one are needed. |
|
@daxian-dbw Judging from BeOfType tests, it is intended for Passing a RuntimeType might be preferable because:
using namespace System.Management.Automation
Describe "scope test" {
$p = [ActionPreference]::Continue
it "should recognise type passed explicitly" {
$p | Should -BeOfType ([ActionPreference]) # Passes
}
it "should recognise type passed as string" {
$p | Should -BeOfType ActionPreference # Fails
}
} |
|
Usually we use |
|
@iSazonov The parentheses are necessary for the parser to treat the token |
|
@xtqqczze I won't say either a RuntimeType or a string is preferable. Both are officially supported and both are useful. If you don't expect the type resolution to depend on anything from your script scope, then using a string is just fine. So I don't think it's necessary to change all |
iSazonov
left a comment
There was a problem hiding this comment.
LGTM with one comment.
test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1
Outdated
Show resolved
Hide resolved
```powershell $_ -ireplace '(\| Should(?: -Not)? -Be)\snull\b','$1 $null' ```
``powershell $_ -ireplace '(\| Should(?: -Not)?)\s-?beoftype\s([a-z]\S*)','$1 -BeOfType ([$2])' ```
```powershell $_ -ireplace '(\| Should(?: -Not)?)\s-?beoftype\s"([^"]+)"','$1 -BeOfType ([$2])' ```
```powershell $_ -ireplace "(\| Should(?: -Not)?)\s-?beoftype\s'([^'']+)'",'$1 -BeOfType ([$2])' ```
0c021ed to
bd1ad61
Compare
|
rebased to resolve merge confilcts |
test/powershell/Modules/Microsoft.PowerShell.Security/CertificateProvider.Tests.ps1
Show resolved
Hide resolved
|
🎉 Handy links: |
PR Summary
.vscode/settings.jsonBeOfTypeparameter: remove unnecessary bracesPR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.