Skip to content
Open
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
30 changes: 30 additions & 0 deletions tests/Clear-PSBuildOutputFolder.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}
}