From db338c2b9abd14cca2120eb42a23600d93851538 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Wed, 4 Nov 2015 15:13:21 -0800 Subject: [PATCH] Fix Pester tests These fail with the improved console because $input is already defined. --- src/pester-tests/Format-List.Tests.ps1 | 28 ++++++++++++------------- src/pester-tests/New-Variable.Tests.ps1 | 10 ++++----- src/pester-tests/Out-File.Tests.ps1 | 22 +++++++++---------- src/pester-tests/Set-Variable.Tests.ps1 | 4 ++-- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/pester-tests/Format-List.Tests.ps1 b/src/pester-tests/Format-List.Tests.ps1 index ac8945f00..e1f807c76 100644 --- a/src/pester-tests/Format-List.Tests.ps1 +++ b/src/pester-tests/Format-List.Tests.ps1 @@ -1,34 +1,34 @@ Describe "Format-List" { BeforeEach { - $input = New-Object PSObject - Add-Member -InputObject $input -MemberType NoteProperty -Name testName -Value testValue + $in = New-Object PSObject + Add-Member -InputObject $in -MemberType NoteProperty -Name testName -Value testValue } It "Should call format list without error" { - { $input | Format-List } | Should Not Throw - { $input | Format-List } | Should Not BeNullOrEmpty + { $in | Format-List } | Should Not Throw + { $in | Format-List } | Should Not BeNullOrEmpty } It "Should be able to call the alias" { - { $input | fl } | Should Not Throw - { $input | fl } | Should Not BeNullOrEmpty + { $in | fl } | Should Not Throw + { $in | fl } | Should Not BeNullOrEmpty } It "Should have the same output whether choosing alias or not" { - $expected = $input | Format-List | Out-String - $actual = $input | fl | Out-String + $expected = $in | Format-List | Out-String + $actual = $in | fl | Out-String $actual | Should Be $expected } It "Should produce the expected output" { $expected = "`n`ntestName : testValue`n`n`n`n" - $input = New-Object PSObject - Add-Member -InputObject $input -MemberType NoteProperty -Name testName -Value testValue + $in = New-Object PSObject + Add-Member -InputObject $in -MemberType NoteProperty -Name testName -Value testValue - $input | Format-List | Should Not BeNullOrEmpty - $input | Format-List | Out-String | Should Not BeNullOrEmpty - $input | Format-List | Out-String | Should Be $expected + $in | Format-List | Should Not BeNullOrEmpty + $in | Format-List | Out-String | Should Not BeNullOrEmpty + $in | Format-List | Out-String | Should Be $expected } It "Should be able to call a property of the piped input" { @@ -64,7 +64,7 @@ Describe "Format-List" { } It "Should be able to take input without piping objects to it" { - $output = { Format-List -InputObject $input } + $output = { Format-List -InputObject $in } $output | Should Not Throw $output | Should Not BeNullOrEmpty diff --git a/src/pester-tests/New-Variable.Tests.ps1 b/src/pester-tests/New-Variable.Tests.ps1 index b45520d7c..32980f0ab 100644 --- a/src/pester-tests/New-Variable.Tests.ps1 +++ b/src/pester-tests/New-Variable.Tests.ps1 @@ -49,18 +49,18 @@ } It "Should be able to set the value of a variable by piped input" { - $input = "value" + $in = "value" - $input | New-Variable -Name var1 + $in | New-Variable -Name var1 - $var1 | Should Be $input + $var1 | Should Be $in } It "Should be able to pipe object properties to output using the PassThru switch" { - $input = Set-Variable -Name testVar -Value "test" -Description "test description" -PassThru + $in = Set-Variable -Name testVar -Value "test" -Description "test description" -PassThru - $output = $input | Format-List -Property Description | Out-String + $output = $in | Format-List -Property Description | Out-String $output | Should Be "`n`nDescription : test description`n`n`n`n" } diff --git a/src/pester-tests/Out-File.Tests.ps1 b/src/pester-tests/Out-File.Tests.ps1 index c7c9a921a..64f106352 100644 --- a/src/pester-tests/Out-File.Tests.ps1 +++ b/src/pester-tests/Out-File.Tests.ps1 @@ -1,6 +1,6 @@ Describe "Out-File" { $expectedContent = "some test text" - $inputObject = New-Object psobject -Property @{text=$expectedContent} + $inObject = New-Object psobject -Property @{text=$expectedContent} $testfile = "/tmp/outfileTest.txt" AfterEach { @@ -28,17 +28,17 @@ } It "Should be able to accept object input" { - { $inputObject | Out-File -FilePath $testfile } | Should Not Throw + { $inObject | Out-File -FilePath $testfile } | Should Not Throw - { Out-File -FilePath $testfile -InputObject $inputObject } | Should Not Throw + { Out-File -FilePath $testfile -InputObject $inObject } | Should Not Throw } It "Should not overwrite when the noclobber switch is used" { - Out-File -FilePath $testfile -InputObject $inputObject + Out-File -FilePath $testfile -InputObject $inObject - { Out-File -FilePath $testfile -InputObject $inputObject -NoClobber -ErrorAction SilentlyContinue } | Should Throw "already exists." - { Out-File -FilePath $testfile -InputObject $inputObject -NoOverWrite -ErrorAction SilentlyContinue } | Should Throw "already exists." + { Out-File -FilePath $testfile -InputObject $inObject -NoClobber -ErrorAction SilentlyContinue } | Should Throw "already exists." + { Out-File -FilePath $testfile -InputObject $inObject -NoOverWrite -ErrorAction SilentlyContinue } | Should Throw "already exists." $actual = Get-Content $testfile @@ -49,8 +49,8 @@ } It "Should Append a new line when the append switch is used" { - { Out-File -FilePath $testfile -InputObject $inputObject } | Should Not Throw - { Out-File -FilePath $testfile -InputObject $inputObject -Append } | Should Not Throw + { Out-File -FilePath $testfile -InputObject $inObject } | Should Not Throw + { Out-File -FilePath $testfile -InputObject $inObject -Append } | Should Not Throw $actual = Get-Content $testfile @@ -71,7 +71,7 @@ It "Should limit each line to the specified number of characters when the width switch is used on objects" { - Out-File -FilePath $testfile -Width 10 -InputObject $inputObject + Out-File -FilePath $testfile -Width 10 -InputObject $inObject $actual = Get-Content $testfile @@ -84,11 +84,11 @@ It "Should allow the cmdlet to overwrite an existing read-only file" { # create a read-only text file - { Out-File -FilePath $testfile -InputObject $inputObject } | Should Not Throw + { Out-File -FilePath $testfile -InputObject $inObject } | Should Not Throw Set-ItemProperty -Path $testfile -Name IsReadOnly -Value $true # write information to the RO file - { Out-File -FilePath $testfile -InputObject $inputObject -Append -Force } | Should Not Throw + { Out-File -FilePath $testfile -InputObject $inObject -Append -Force } | Should Not Throw $actual = Get-Content $testfile diff --git a/src/pester-tests/Set-Variable.Tests.ps1 b/src/pester-tests/Set-Variable.Tests.ps1 index 0b43552cb..46f87e496 100644 --- a/src/pester-tests/Set-Variable.Tests.ps1 +++ b/src/pester-tests/Set-Variable.Tests.ps1 @@ -48,9 +48,9 @@ } It "Should be able to pipe object properties to output using the PassThru switch" { - $input = Set-Variable -Name testVar -Value "test" -Description "test description" -PassThru + $in = Set-Variable -Name testVar -Value "test" -Description "test description" -PassThru - $output = $input | Format-List -Property Description | Out-String + $output = $in | Format-List -Property Description | Out-String # This will cause errors running these tests in windows $output | Should Be "`n`nDescription : test description`n`n`n`n"