mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Code cleanup for Get-Content to make -Head and -Tail disallow negative values (#19715)
This commit is contained in:
@@ -72,6 +72,14 @@ Describe "Get-Content" -Tags "CI" {
|
||||
Get-Content -Path $testPath2 -Last 1 | Should -BeExactly $fifthline
|
||||
}
|
||||
|
||||
It 'Verifies -TotalCount reports a ParameterArgumentValidationError error for negative values' {
|
||||
{Get-Content -Path $testPath2 -TotalCount -2} | Should -Throw -ErrorId 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetContentCommand'
|
||||
}
|
||||
|
||||
It 'Verifies -Tail reports a ParameterArgumentValidationError error for negative values' {
|
||||
{Get-Content -Path $testPath2 -Tail -2} | Should -Throw -ErrorId 'ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetContentCommand'
|
||||
}
|
||||
|
||||
It "Should be able to get content within a different drive" {
|
||||
Push-Location env:
|
||||
$expectedoutput = [Environment]::GetEnvironmentVariable("PATH");
|
||||
@@ -271,6 +279,10 @@ Describe "Get-Content" -Tags "CI" {
|
||||
Get-Content -Path $testPath -TotalCount 0 | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Should return no content when -Tail value is 0" {
|
||||
Get-Content -Path $testPath -Tail 0 | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Should throw TailAndHeadCannotCoexist when both -Tail and -TotalCount are used" {
|
||||
{
|
||||
Get-Content -Path $testPath -Tail 1 -TotalCount 1 -ErrorAction Stop
|
||||
|
||||
Reference in New Issue
Block a user