mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Update pester syntax to v4 (#11544)
* Capitalize 'Should' command and fix whitespace ```powershell $_ -ireplace '\s?\|\s?should\b',' | Should' ``` * Capitalise and apply hyphen to 'Not' parameter ```powershell $_ -ireplace '(\| Should) not\b','$1 -Not' ``` * Capitalise and apply hyphen to 'Be' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?) -?be\b','$1 -Be' ``` * Capitalise and apply hyphen to 'BeExactly' parameter $_ -ireplace '(\| Should(?: -Not)?) -?beexactly\b','$1 -BeExactly' * Capitalise and apply hyphen to 'BeGreaterThan' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?) -?begreaterthan\b','$1 -BeGreaterThan' ``` * Use 'BeTrue' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?true\b','$1 -BeTrue' ``` * Use 'BeFalse' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?) -Be\s\$?false\b','$1 -BeFalse' ``` * Capitalise and apply hyphen to 'Match' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?)\s-?match\b','$1 -Match' ``` * Capitalise and apply hyphen to 'Throw' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?)\s-?throw\b','$1 -Throw' ``` * Capitalise and apply hyphen to 'BeNullOrEmpty' parameter ```powershell $_ -ireplace '(\| Should(?: -Not)?)\s-?benullorempty\b','$1 -BeNullOrEmpty' ``` * Capitalise 'Because' parameter ```powershell $_ -ireplace '\s-because\b',' -Because' ``` * Fix 'BeNullOrEmpty'
This commit is contained in:
1 parent
70d9ed4d55
commit
743983390e
71 files changed
+979
-979
No files matched your search
@@ -30,7 +30,7 @@ Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
||||
|
||||
It 'Check union of default + one allowed variables' {
|
||||
|
||||
{ { 2 + $a }.CheckRestrictedLanguage($null, (list a), $false) }| Should -Not -Throw # succeed
|
||||
{ { 2 + $a }.CheckRestrictedLanguage($null, (list a), $false) } | Should -Not -Throw # succeed
|
||||
}
|
||||
|
||||
It 'Check union of default + two allowed variables' {
|
||||
@@ -40,7 +40,7 @@ Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
||||
|
||||
It 'Check union of default + allowed variables' {
|
||||
|
||||
{ { $PSCulture, $PSUICulture, $true, $false, $null, $a, $b}.CheckRestrictedLanguage($null, (list a b), $false) }| Should -Not -Throw
|
||||
{ { $PSCulture, $PSUICulture, $true, $false, $null, $a, $b}.CheckRestrictedLanguage($null, (list a b), $false) } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It 'Check union of default + one disallowed variables' {
|
||||
@@ -70,6 +70,6 @@ Describe "Test restricted language check method on scriptblocks" -Tags "CI" {
|
||||
{ { get-process | where name -Match $pattern | foreach $prop }.CheckRestrictedLanguage(
|
||||
(list get-process where foreach),
|
||||
(list prop pattern)
|
||||
, $false) }| Should -Not -Throw
|
||||
, $false) } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
|
||||
# Exception: "Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: error foo"
|
||||
|
||||
# BUG in runspace api.
|
||||
#$ps.error.count | Should Be 1
|
||||
#$ps.error.count | Should -Be 1
|
||||
|
||||
$ps.InvocationStateInfo.State | Should -BeExactly 'Failed'
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ Describe "Tests conversion of deserialized types to original type using object p
|
||||
}
|
||||
|
||||
It 'Type casts should succeed.' {
|
||||
{ $tc1 = [test1]$dst1 }| Should -Not -Throw
|
||||
{ $tc1 = [test1]$dst1 } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It 'Parameter bindings should succeed.' {
|
||||
|
||||
@@ -52,7 +52,7 @@ Describe 'Native UNIX globbing tests' -tags "CI" {
|
||||
It 'Should not normalize absolute paths' {
|
||||
$matches = /bin/echo /etc/*
|
||||
# Matched path should start with '/etc/' not '../..'
|
||||
$matches.substring(0,5) | Should Be '/etc/'
|
||||
$matches.substring(0,5) | Should -Be '/etc/'
|
||||
}
|
||||
It 'Globbing should not happen with quoted expressions' {
|
||||
$v = "$TESTDRIVE/abc*"
|
||||
|
||||
@@ -379,7 +379,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
||||
$p
|
||||
}
|
||||
|
||||
get-fooe| Should -Be 55
|
||||
get-fooe | Should -Be 55
|
||||
}
|
||||
|
||||
It "Validation attributes should not run on default values when CmdletBinding is set on the parameter" {
|
||||
@@ -390,7 +390,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
||||
$p
|
||||
}
|
||||
|
||||
get-foof| Should -Be 55
|
||||
get-foof | Should -Be 55
|
||||
}
|
||||
|
||||
It "Validation attributes should not run on default values" {
|
||||
@@ -400,7 +400,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
||||
$p
|
||||
}
|
||||
|
||||
{ get-foog } | Should -Not -throw
|
||||
{ get-foog } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Validation attributes should not run on default values when CmdletBinding is set" {
|
||||
@@ -411,7 +411,7 @@ Describe "Tests for parameter binding" -Tags "CI" {
|
||||
$p
|
||||
}
|
||||
|
||||
{ get-fooh } | Should -Not -throw
|
||||
{ get-fooh } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "ValidateScript can use custom ErrorMessage" {
|
||||
|
||||
@@ -17,7 +17,7 @@ Describe '$env:__SuppressAnsiEscapeSequences tests' -Tag CI {
|
||||
}
|
||||
|
||||
It 'Select-String emits VT' {
|
||||
"select this string" | Select-String 'this' | Out-String |Should -BeLikeExactly "*`e*"
|
||||
"select this string" | Select-String 'this' | Out-String | Should -BeLikeExactly "*`e*"
|
||||
}
|
||||
|
||||
It 'ConciseView emits VT' {
|
||||
|
||||
Reference in new issue
Block a user