mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-05-04 08:41:36 +00:00
0138dc4266
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
46 lines
1.3 KiB
PowerShell
46 lines
1.3 KiB
PowerShell
BeforeAll {
|
|
. "$PSScriptRoot\Scoop-TestLib.ps1"
|
|
. "$PSScriptRoot\..\lib\core.ps1"
|
|
. "$PSScriptRoot\..\lib\commands.ps1"
|
|
}
|
|
|
|
Describe 'Manipulate Alias' -Tag 'Scoop' {
|
|
BeforeAll {
|
|
Mock shimdir { "$TestDrive\shims" }
|
|
Mock set_config {}
|
|
Mock get_config { @{} }
|
|
|
|
$shimdir = shimdir
|
|
ensure $shimdir
|
|
}
|
|
|
|
It 'Creates a new alias if it does not exist' {
|
|
$alias_script = "$shimdir\scoop-rm.ps1"
|
|
$alias_script | Should -Not -Exist
|
|
|
|
add_alias 'rm' '"hello, world!"'
|
|
& $alias_script | Should -Be 'hello, world!'
|
|
}
|
|
|
|
It 'Skips an existing alias' {
|
|
$alias_script = "$shimdir\scoop-rm.ps1"
|
|
Mock abort {}
|
|
New-Item $alias_script -Type File -Force
|
|
$alias_script | Should -Exist
|
|
|
|
add_alias 'rm' '"test"'
|
|
Should -Invoke -CommandName abort -Times 1 -ParameterFilter { $msg -eq "File 'scoop-rm.ps1' already exists in shims directory." }
|
|
}
|
|
|
|
It 'Removes an existing alias' {
|
|
$alias_script = "$shimdir\scoop-rm.ps1"
|
|
$alias_script | Should -Exist
|
|
Mock get_config { @(@{'rm' = 'scoop-rm' }) }
|
|
Mock info {}
|
|
|
|
rm_alias 'rm'
|
|
$alias_script | Should -Not -Exist
|
|
Should -Invoke -CommandName info -Times 1 -ParameterFilter { $msg -eq "Removing alias 'rm'..." }
|
|
}
|
|
}
|