From eaf2595c24c2551798629f19a5e9abc58b786db6 Mon Sep 17 00:00:00 2001 From: Nathanael BOT Date: Tue, 3 Mar 2026 23:00:31 +0100 Subject: [PATCH] test: add coverage for Clear-PSBuildOutputFolder (#94) --- tests/Clear-PSBuildOutputFolder.tests.ps1 | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/Clear-PSBuildOutputFolder.tests.ps1 diff --git a/tests/Clear-PSBuildOutputFolder.tests.ps1 b/tests/Clear-PSBuildOutputFolder.tests.ps1 new file mode 100644 index 0000000..920cc21 --- /dev/null +++ b/tests/Clear-PSBuildOutputFolder.tests.ps1 @@ -0,0 +1,28 @@ +Describe 'Clear-PSBuildOutputFolder' { + + BeforeAll { + $script:moduleName = 'PowerShellBuild' + $script:moduleRoot = Split-Path -Path $PSScriptRoot -Parent + Import-Module ([IO.Path]::Combine($script:moduleRoot, 'Output', $script:moduleName)) -Force + } + + It 'removes the target folder when it exists' { + $path = Join-Path -Path $TestDrive -ChildPath 'OutputFolder' + New-Item -Path $path -ItemType Directory -Force | Out-Null + New-Item -Path (Join-Path -Path $path -ChildPath 'artifact.txt') -ItemType File -Force | Out-Null + + Clear-PSBuildOutputFolder -Path $path + + $path | Should -Not -Exist + } + + It 'does not throw when the target folder does not exist' { + $path = Join-Path -Path $TestDrive -ChildPath 'MissingFolder' + + { Clear-PSBuildOutputFolder -Path $path } | Should -Not -Throw + } + + It 'rejects paths with 3 or fewer characters' { + { Clear-PSBuildOutputFolder -Path 'abc' } | Should -Throw + } +}