mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Don't add trailing spaces to last column when using Format-Table (#5568)
* don't add trailing space to last column in table * fix out-file tests to new behavior of no padding trailing spaces
This commit is contained in:
1 parent
03ac50ade1
commit
bdd6008846
3 files changed
+58
-49
No files matched your search
@@ -137,44 +137,23 @@ Describe "Format-Table DRT Unit Tests" -Tags "CI" {
|
||||
$result | Should Match "Jim\s+5678\s+False"
|
||||
}
|
||||
|
||||
It "Format-Table with No Objects for End-To-End should work"{
|
||||
$p = @{}
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
It "Format-Table with '<testName>' should return `$null" -TestCases @(
|
||||
@{ testName = "empty array"; testObject = @{} },
|
||||
@{ testName = "null" ; testObject = $null }
|
||||
) {
|
||||
param ($testObject)
|
||||
$result = $testObject | Format-Table -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Format-Table with Null Objects for End-To-End should work"{
|
||||
$p = $null
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-Table with single line string for End-To-End should work" -pending{
|
||||
$p = "single line string"
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-Table with multiple line string for End-To-End should work" -pending{
|
||||
$p = "Line1\nLine2"
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-Table with string sequence for End-To-End should work" -pending{
|
||||
$p = "Line1","Line2"
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-Table with string sequence for End-To-End should work" -pending{
|
||||
$p = "Line1","Line2"
|
||||
$result = $p|Format-Table -Property "foo","bar"|Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
It "Format-Table with '<testName>' string and -Force should output table with requested properties" -TestCases @(
|
||||
@{ testName = "single line"; testString = "single line string" },
|
||||
@{ testName = "multi line" ; testString = "line1`nline2" },
|
||||
@{ testName = "array" ; testString = "line1","line2" }
|
||||
) {
|
||||
param ($testString)
|
||||
$result = $testString | Format-Table -Property "foo","bar" -Force | Out-String
|
||||
$result.Replace(" ","").Replace([Environment]::NewLine,"") | Should BeExactly "foobar------"
|
||||
}
|
||||
|
||||
It "Format-Table with complex object for End-To-End should work" {
|
||||
@@ -211,4 +190,14 @@ Describe "Format-Table DRT Unit Tests" -Tags "CI" {
|
||||
$result3 | Should Match "name\s+sub"
|
||||
$result3 | Should Match "this is name\s+{x 0 y 0, x 1 y 1}"
|
||||
}
|
||||
|
||||
It "Format-Table should not add trailing whitespace to the header" {
|
||||
$out = "hello" | Format-Table -Property foo -Force | Out-String
|
||||
$out.Replace([System.Environment]::NewLine, "") | Should BeExactly "foo---"
|
||||
}
|
||||
|
||||
It "Format-Table should not add trailing whitespace to rows" {
|
||||
$out = [pscustomobject]@{a=1;b=2} | Format-Table -HideTableHeaders | Out-String
|
||||
$out.Replace([System.Environment]::NewLine, "") | Should BeExactly "1 2"
|
||||
}
|
||||
}
|
||||
@@ -98,8 +98,8 @@ Describe "Out-File" -Tags "CI" {
|
||||
$actual = Get-Content $testfile
|
||||
|
||||
$actual[0] | Should Be ""
|
||||
$actual[1] | Should Be "text "
|
||||
$actual[2] | Should Be "---- "
|
||||
$actual[1] | Should Be "text"
|
||||
$actual[2] | Should Be "----"
|
||||
$actual[3] | Should Be "some te..."
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ Describe "Out-File" -Tags "CI" {
|
||||
# reset to not read only so it can be deleted
|
||||
Set-ItemProperty -Path $testfile -Name IsReadOnly -Value $false
|
||||
}
|
||||
|
||||
|
||||
It "Should be able to use the 'Path' alias for the 'FilePath' parameter" {
|
||||
{ Out-File -Path $testfile } | Should Not Throw
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user