51 lines
1.8 KiB
PowerShell
51 lines
1.8 KiB
PowerShell
Describe 'Install-WinAcme' {
|
|
BeforeAll {
|
|
function Uninstall-WinAcme {
|
|
param (
|
|
[string]$DestinationPath
|
|
)
|
|
|
|
# Remove the installation directory
|
|
if (Test-Path -Path $DestinationPath) {
|
|
Remove-Item -Path $DestinationPath -Recurse -Force
|
|
}
|
|
|
|
# Remove from PATH
|
|
$env:PATH = $env:PATH -replace [regex]::Escape("$DestinationPath\"), ''
|
|
[Environment]::SetEnvironmentVariable("Path", $env:PATH, [System.EnvironmentVariableTarget]::Machine)
|
|
}
|
|
|
|
# Clean up any existing win-acme installation
|
|
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
|
|
|
# Load the Install-WinAcme function
|
|
Set-Item function:Install-WinAcme ([ScriptBlock]::Create((Get-Content -Raw 'windows\Install-WinAcme.ps1')))
|
|
}
|
|
|
|
It 'Has the correct parameters' {
|
|
$params = (Get-Command Install-WinAcme).Parameters
|
|
|
|
$params.ContainsKey('DestinationPath') | Should -Be $true
|
|
$params['DestinationPath'].ParameterType.Name | Should -Be 'String'
|
|
}
|
|
|
|
It 'Should download and install win-acme without errors' {
|
|
{ Install-WinAcme -DestinationPath 'C:\Program Files\win-acme' } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should add win-acme to the system PATH' {
|
|
$env:PATH | Should -Match 'C:\\Program Files\\win-acme\\'
|
|
}
|
|
|
|
It 'Should create the win-acme installation directory' {
|
|
Test-Path -Path 'C:\Program Files\win-acme' | Should -Be $true
|
|
}
|
|
|
|
It 'Should create the wacs executable in the installation directory' {
|
|
Test-Path -Path 'C:\Program Files\win-acme\wacs.exe' | Should -Be $true
|
|
}
|
|
|
|
AfterAll {
|
|
Uninstall-WinAcme -DestinationPath 'C:\Program Files\win-acme'
|
|
}
|
|
} |