Fix tests that were broken by the sxs module path change. Also fix some unreliable tests.

This commit is contained in:
Dongbo Wang committed 2016-08-11 21:45:20 -07:00
1 parent 896577e285
commit 753b202a75
8 files changed
+29 -26

No files matched your search

@@ -1,6 +1,6 @@
Describe "Export-Csv" -Tags "CI" {
$testObject = @("test","object","array")
$testCsv = "output.csv"
$testCsv = Join-Path -Path $TestDrive -ChildPath "output.csv"
AfterEach {
Remove-Item $testCsv -Force -ErrorAction SilentlyContinue
@@ -51,7 +51,7 @@ Describe "Export-Csv" -Tags "CI" {
It "Should have the same information when using the alias vs the cmdlet" {
$testObject | Export-Csv -Path $testCsv
$aliasObject = "alias.csv"
$aliasObject = Join-Path -Path $TestDrive -ChildPath "alias.csv"
$testObject | epcsv -Path $aliasObject
@@ -16,26 +16,29 @@ Describe "Export-FormatData DRT Unit Tests" -Tags "CI" {
Describe "Export-FormatData" -Tags "CI" {
$testOutput = Join-Path -Path $TestDrive -ChildPath "outputfile"
AfterEach {
Remove-Item $testOutput -Force -ErrorAction SilentlyContinue
}
Context "Check Export-FormatData can be called validly." {
It "Should be able to be called without error" {
{ Get-FormatData | Export-FormatData -Path "outputfile" } | Should Not Throw
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
}
It "Should be able to be called without error" {
{ Get-FormatData | Export-FormatData -Path $testOutput } | Should Not Throw
}
}
Context "Check that the output is in the correct format" {
It "Should not return an empty xml file" {
Get-FormatData | Export-FormatData -Path "outputfile"
$piped = Get-Content "outputfile"
$piped | Should Not Be ""
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
}
It "Should not return an empty xml file" {
Get-FormatData | Export-FormatData -Path $testOutput
$piped = Get-Content $testOutput
$piped | Should Not Be ""
}
It "Should have a valid xml tag at the start of the file" {
Get-FormatData | Export-FormatData -Path "outputfile"
$piped = Get-Content "outputfile"
$piped[0] | Should Be "<"
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
}
It "Should have a valid xml tag at the start of the file" {
Get-FormatData | Export-FormatData -Path $testOutput
$piped = Get-Content $testOutput
$piped[0] | Should Be "<"
}
}
}
@@ -1,6 +1,6 @@
Describe "Out-File DRT Unit Tests" -Tags "CI" {
It "Should be able to write the contens into a file with -pspath" {
$tempFile = "ExposeBug928965"
$tempFile = Join-Path -Path $TestDrive -ChildPath "ExposeBug928965"
{ 1 | Out-File -PSPath $tempFile } | Should Not Throw
$fileContents = Get-Content $tempFile
$fileContents | Should be 1
@@ -8,7 +8,7 @@ Describe "Out-File DRT Unit Tests" -Tags "CI" {
}
It "Should be able to write the contens into a file with -pspath" {
$tempFile = "outfileAppendTest.txt"
$tempFile = Join-Path -Path $TestDrive -ChildPath "outfileAppendTest.txt"
{ 'This is first line.' | out-file $tempFile } | Should Not Throw
{ 'This is second line.' | out-file -append $tempFile } | Should Not Throw
$tempFile |Should Contain "first"
@@ -1,5 +1,5 @@
Describe "Stream writer tests" -Tags "CI" {
$targetfile = "writeoutput.txt"
$targetfile = Join-Path -Path $TestDrive -ChildPath "writeoutput.txt"
# A custom function is defined here do handle the debug stream dealing with the confirm prompt
# that would normally