-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathClear-PSBuildOutputFolder.tests.ps1
More file actions
30 lines (22 loc) · 1.14 KB
/
Clear-PSBuildOutputFolder.tests.ps1
File metadata and controls
30 lines (22 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Describe 'Clear-PSBuildOutputFolder' {
BeforeAll {
Import-Module "$PSScriptRoot/../PowerShellBuild/PowerShellBuild.psd1" -Force
}
It 'throws when Path is 3 chars or fewer' {
{ Clear-PSBuildOutputFolder -Path 'abc' } | Should -Throw
}
It 'removes an existing output folder recursively' {
$tempRoot = Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath ([guid]::NewGuid().ToString())
$outputPath = Join-Path -Path $tempRoot -ChildPath 'output-folder'
$nestedDir = Join-Path -Path $outputPath -ChildPath 'nested'
New-Item -ItemType Directory -Path $nestedDir -Force | Out-Null
New-Item -ItemType File -Path (Join-Path -Path $nestedDir -ChildPath 'artifact.txt') -Force | Out-Null
$outputPath | Should -Exist
Clear-PSBuildOutputFolder -Path $outputPath
$outputPath | Should -Not -Exist
}
It 'does nothing when the target path does not exist' {
$missingPath = Join-Path -Path ([IO.Path]::GetTempPath()) -ChildPath ("missing-" + [guid]::NewGuid().ToString())
{ Clear-PSBuildOutputFolder -Path $missingPath } | Should -Not -Throw
}
}