Clean up temp files in pester scripts

This commit is contained in:
George Fleming authored and Andrew Schwartzmeyer committed 2016-02-08 10:59:02 -08:00
1 parent 363c0ccfd1
commit cb6d7011d9
4 files changed
+14 -1

No files matched your search

+5
View File
@@ -18,6 +18,11 @@
New-Item -Path $testPath2 -ItemType file -Force -Value $testString2
}
AfterEach {
Remove-Item -Path $testPath -Force
Remove-Item -Path $testPath2 -Force
}
It "Should throw an error on a directory " {
# also tests that -erroraction SilentlyContinue will work.
Get-Content . -ErrorAction SilentlyContinue | Should Throw
+3 -1
View File
@@ -17,7 +17,7 @@ Describe "Get-ItemProperty" {
}
New-Item $tempDirectory -ItemType Directory -Force
$testfile = $tempDirectory + [Environment]::DirectorySeparatorChar + "testfile1"
$testfile = $tempDirectory + [System.IO.Path]::DirectorySeparatorChar + "testfile1"
New-Item $testfile -ItemType file -Force
@@ -62,4 +62,6 @@ Describe "Get-ItemProperty" {
$alias.PSDrive | Should Be $cmdlet.PSDrive
$alias.PSProvider.Name | Should Be $cmdlet.PSProvider.Name
}
Remove-Item $tempDirectory -Recurse -Force
}
+4
View File
@@ -104,6 +104,10 @@
New-Item $testInputFile -Itemtype "file" -Force -Value "This is a text string, and another string${nl}This is the second line${nl}This is the third line${nl}This is the fourth line${nl}No matches"
}
AfterEach {
Remove-Item $testInputFile -Force
}
It "Should return an object when a match is found is the file on only one line" {
(Select-String $testInputFile -Pattern "string").GetType().BaseType | Should be System.Object
}
+2
View File
@@ -71,4 +71,6 @@ Describe "Start-Process" {
$dirEntry = dir $tempFile
$dirEntry.Length | Should BeGreaterThan 0
}
Remove-Item -Path $tempFile -Force
}