Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Functions/Cleanup.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ Describe "Cleanup" {

It "should also remove the TestDrive:" {
Test-Path "TestDrive:\foo" | Should Not Exist
}
}

}

Describe "Cleanup when Remove-Item is mocked" {

Mock Remove-Item {}

Context "add a temp directory" {
Setup -Dir "foo"
}

Context "next context" {

It "should have removed the temp folder" {
"$TestDrive\foo" | Should Not Exist
}

}

}

11 changes: 6 additions & 5 deletions Functions/Cleanup.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
function Cleanup() {
if (Test-Path $TestDrive) {
Remove-Item $TestDrive -Recurse -Force
function Cleanup {
Clear-Mocks

if (Test-Path $TestDrive) {
Microsoft.PowerShell.Management\Remove-Item $TestDrive -Recurse -Force
Remove-PSDrive -Name TestDrive -Scope Global -Force
}
Clear-Mocks
}
}