mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Clean up temp files in pester scripts
This commit is contained in:
1 parent
363c0ccfd1
commit
cb6d7011d9
4 files changed
+14
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -71,4 +71,6 @@ Describe "Start-Process" {
|
||||
$dirEntry = dir $tempFile
|
||||
$dirEntry.Length | Should BeGreaterThan 0
|
||||
}
|
||||
|
||||
Remove-Item -Path $tempFile -Force
|
||||
}
|
||||
Reference in new issue
Block a user