From 2bd274f5d7c656cf8dc42d4dcc82568c858b4a9f Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 8 Apr 2016 13:36:54 -0700 Subject: [PATCH] Fix tests broken by removal of aliases --- test/powershell/Compare-Object.Tests.ps1 | 29 ------------------- test/powershell/Export-Alias.Tests.ps1 | 2 +- test/powershell/Get-ChildItem.Tests.ps1 | 4 --- test/powershell/Get-Content.Tests.ps1 | 12 ++------ test/powershell/Get-Item.Tests.ps1 | 2 +- test/powershell/NativeLinuxCommands.Tests.ps1 | 28 +++++++----------- test/powershell/Start-Sleep.Tests.ps1 | 5 ---- test/powershell/Tee-Object.Tests.ps1 | 18 ++---------- 8 files changed, 17 insertions(+), 83 deletions(-) diff --git a/test/powershell/Compare-Object.Tests.ps1 b/test/powershell/Compare-Object.Tests.ps1 index 9640105a6..db61154a8 100644 --- a/test/powershell/Compare-Object.Tests.ps1 +++ b/test/powershell/Compare-Object.Tests.ps1 @@ -35,35 +35,6 @@ Describe "Compare-Object" { { Compare-Object -ReferenceObject $(Get-Content $file1) $(Get-Content $file2) } | Should Not Throw } - It "Should be able to execute compare object using the compare alias" { - { compare -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) } | Should Not Throw - } - - It "Should produce the same output when the compare alias is used" { - $alias = compare -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) - $fullname = Compare-Object -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) - - $alias[0].InputObject | Should Be $fullname[0].InputObject - $alias[0].SideIndicator | Should Be $fullname[0].SideIndicator - $alias[1].InputObject | Should Be $fullname[1].InputObject - $alias[1].SideIndicator | Should Be $fullname[1].SideIndicator - - $alias.Length | Should Be 2 # There should be no other elements to test - - } - - It "Should be able to execute compare object using the diff alias" { - $alias = diff -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) - $fullname = Compare-Object -ReferenceObject $(Get-Content $file1) -DifferenceObject $(Get-Content $file2) - - $alias[0].InputObject | Should Be $fullname[0].InputObject - $alias[0].SideIndicator | Should Be $fullname[0].SideIndicator - $alias[1].InputObject | Should Be $fullname[1].InputObject - $alias[1].SideIndicator | Should Be $fullname[1].SideIndicator - - $alias.Length | Should Be 2 # There should be no other elements to test - } - It "Should indicate data that exists only in the reference dataset" { $actualOutput = Compare-Object -ReferenceObject $(Get-Content $file3) -DifferenceObject $(Get-Content $file4) diff --git a/test/powershell/Export-Alias.Tests.ps1 b/test/powershell/Export-Alias.Tests.ps1 index 7a7a459de..a51ad64ef 100644 --- a/test/powershell/Export-Alias.Tests.ps1 +++ b/test/powershell/Export-Alias.Tests.ps1 @@ -144,7 +144,7 @@ Describe "Export-Alias" { Test-Path $fulltestpath | Should Be $true - $actual = Get-Content $fulltestpath | Sort + $actual = Get-Content $fulltestpath | Sort-Object $expected = Get-Command -CommandType Alias for ( $i=0; $i -lt $expected.Length; $i++) diff --git a/test/powershell/Get-ChildItem.Tests.ps1 b/test/powershell/Get-ChildItem.Tests.ps1 index 331a6259c..6925f6b64 100644 --- a/test/powershell/Get-ChildItem.Tests.ps1 +++ b/test/powershell/Get-ChildItem.Tests.ps1 @@ -9,10 +9,6 @@ Describe "Get-ChildItem" { popd } - It "Should be able to use the ls alias" { - $(ls .).Name.Length | Should Be $(Get-ChildItem .).Name.Length - } - It "Should have a the proper fields and be populated" { $var = Get-Childitem . diff --git a/test/powershell/Get-Content.Tests.ps1 b/test/powershell/Get-Content.Tests.ps1 index 931cc5888..446683878 100644 --- a/test/powershell/Get-Content.Tests.ps1 +++ b/test/powershell/Get-Content.Tests.ps1 @@ -40,10 +40,6 @@ Describe "Get-Content" { (Get-Content -Path $testPath) | Should Be $testString } - It "Should be able to call using the cat alias" { - { cat -Path $testPath } | Should Not Throw - } - It "Should be able to call using the gc alias" { { gc -Path $testPath } | Should Not Throw } @@ -55,11 +51,9 @@ Describe "Get-Content" { It "Should return the same values for aliases" { $getContentAlias = Get-Content -Path $testPath $gcAlias = gc -Path $testPath - $catAlias = cat -Path $testPath $typeAlias = type -Path $testPath $getContentAlias | Should Be $gcAlias - $getContentAlias | Should Be $catAlias $getContentAlias | Should Be $typeAlias } @@ -68,21 +62,21 @@ Describe "Get-Content" { } It "Should be able to specify the number of lines to get the content of using the TotalCount switch" { - $returnArray = (cat -Path $testPath2 -TotalCount 2) + $returnArray = (Get-Content -Path $testPath2 -TotalCount 2) $returnArray[0] | Should Be $firstline $returnArray[1] | Should Be $secondline } It "Should be able to specify the number of lines to get the content of using the Head switch" { - $returnArray = (cat -Path $testPath2 -Head 2) + $returnArray = (Get-Content -Path $testPath2 -Head 2) $returnArray[0] | Should Be $firstline $returnArray[1] | Should Be $secondline } It "Should be able to specify the number of lines to get the content of using the First switch" { - $returnArray = (cat -Path $testPath2 -First 2) + $returnArray = (Get-Content -Path $testPath2 -First 2) $returnArray[0] | Should Be $firstline $returnArray[1] | Should Be $secondline diff --git a/test/powershell/Get-Item.Tests.ps1 b/test/powershell/Get-Item.Tests.ps1 index 92e775006..298236636 100644 --- a/test/powershell/Get-Item.Tests.ps1 +++ b/test/powershell/Get-Item.Tests.ps1 @@ -15,6 +15,6 @@ Describe "Get-Item" { } It "Should have mode flags set" { - ls $PSScriptRoot | foreach-object { $_.Mode | Should Not BeNullOrEmpty } + Get-ChildItem $PSScriptRoot | foreach-object { $_.Mode | Should Not BeNullOrEmpty } } } diff --git a/test/powershell/NativeLinuxCommands.Tests.ps1 b/test/powershell/NativeLinuxCommands.Tests.ps1 index c765ef722..07b776009 100644 --- a/test/powershell/NativeLinuxCommands.Tests.ps1 +++ b/test/powershell/NativeLinuxCommands.Tests.ps1 @@ -1,30 +1,22 @@ Describe "NativeLinuxCommands" { It "Should return a type of System.Object for hostname cmdlet" { - (hostname).GetType().BaseType | Should Be 'System.Object' - (hostname).GetType().Name | Should Be String + (hostname).GetType().BaseType | Should Be 'System.Object' + (hostname).GetType().Name | Should Be String } It "Should have not empty Name flags set for ps object" { - ps | foreach-object { $_.ProcessName | Should Not BeNullOrEmpty } + Get-Process | foreach-object { $_.ProcessName | Should Not BeNullOrEmpty } } - - It "Should find Application grep" -Skip:$IsWindows { - (get-command grep).CommandType | Should Be Application + + It "Should find Application grep" -Skip:$IsWindows { + (get-command grep).CommandType | Should Be Application } It "Should pipe to grep and get result" -Skip:$IsWindows { - "hello world" | grep hello | Should Be "hello world" + "hello world" | grep hello | Should Be "hello world" } - - It "Should find Application touch" -Skip:$IsWindows { - (get-command touch).CommandType | Should Be Application - } - - It "Should find Alias ls" -Skip:$IsWindows { - (get-command ls).CommandType | Should Be Alias - } - - It "Should find Function mkdir" -Skip:$IsWindows { - (get-command mkdir).CommandType | Should Be Function + + It "Should find Application touch" -Skip:$IsWindows { + (get-command touch).CommandType | Should Be Application } } diff --git a/test/powershell/Start-Sleep.Tests.ps1 b/test/powershell/Start-Sleep.Tests.ps1 index e97cfad80..42166de94 100644 --- a/test/powershell/Start-Sleep.Tests.ps1 +++ b/test/powershell/Start-Sleep.Tests.ps1 @@ -24,10 +24,5 @@ Describe "Start-Sleep" { $result = Measure-Command { Start-Sleep -s 1 } $result.TotalSeconds | Should BeGreaterThan 0.25 } - - It "Should sleep for at least 1 second using the alias" { - $result = Measure-Command { sleep -s 1 } - $result.TotalSeconds | Should BeGreaterThan 0.25 - } } } diff --git a/test/powershell/Tee-Object.Tests.ps1 b/test/powershell/Tee-Object.Tests.ps1 index b7b5c8b65..8bd22f45c 100644 --- a/test/powershell/Tee-Object.Tests.ps1 +++ b/test/powershell/Tee-Object.Tests.ps1 @@ -6,15 +6,8 @@ Describe "Tee-Object" { It "Should return the output to the screen and to the variable" { $teefile = $testfile - echo teeobjecttest1 | Tee-Object -variable teeresults - $teeresults | Should Be "teeobjecttest1" - Remove-Item $teefile -ErrorAction SilentlyContinue - } - - It "Should return the output to the screen and to the variable from the alias" { - $teefile = $testfile - echo teeobjecttest2 | tee -variable teeresults - $teeresults | Should Be "teeobjecttest2" + echo teeobjecttest1 | Tee-Object -variable teeresults + $teeresults | Should Be "teeobjecttest1" Remove-Item $teefile -ErrorAction SilentlyContinue } @@ -24,12 +17,5 @@ Describe "Tee-Object" { Get-Content $teefile | Should Be "teeobjecttest3" Remove-Item $teefile -ErrorAction SilentlyContinue } - - It "Should tee the output to a file using the alias" { - $teefile = $testfile - echo teeobjecttest4 | tee $teefile - Get-Content $teefile | Should Be "teeobjecttest4" - Remove-item $teefile -ErrorAction SilentlyContinue - } } }