mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-10-04 02:58:27 +00:00
* Scoop-Alias: remove erroneous output from dot-sourcing the source file * Scoop-Alias: using "TestDrive:\" for mocked shimdir - reduced cleanup - improved robustness; excution is now independent of CWD * Scoop-Core: corrected directory location code - improved robustness; execution is now independent of CWD
56 lines
1.2 KiB
PowerShell
56 lines
1.2 KiB
PowerShell
. "$psscriptroot\..\libexec\scoop-alias.ps1" | out-null
|
|
|
|
reset_aliases
|
|
|
|
describe "add_alias" {
|
|
mock shimdir { "TestDrive:\shim" }
|
|
mock set_config { }
|
|
mock get_config { @{} }
|
|
|
|
$shimdir = shimdir
|
|
mkdir $shimdir
|
|
|
|
context "alias doesn't exist" {
|
|
it "creates a new alias" {
|
|
$alias_file = "$shimdir\scoop-rm.ps1"
|
|
$alias_file | should not exist
|
|
|
|
add_alias "rm" '"hello, world!"'
|
|
iex $alias_file | should be "hello, world!"
|
|
}
|
|
}
|
|
|
|
context "alias exists" {
|
|
it "does not change existing alias" {
|
|
$alias_file = "$shimdir\scoop-rm.ps1"
|
|
new-item $alias_file -type file
|
|
$alias_file | should exist
|
|
|
|
add_alias "rm" "test"
|
|
$alias_file | should contain ""
|
|
}
|
|
}
|
|
}
|
|
|
|
describe "rm_alias" {
|
|
mock shimdir { "TestDrive:\shim" }
|
|
mock set_config { }
|
|
mock get_config { @{} }
|
|
|
|
$shimdir = shimdir
|
|
mkdir $shimdir
|
|
|
|
context "alias exists" {
|
|
it "removes an existing alias" {
|
|
$alias_file = "$shimdir\scoop-rm.ps1"
|
|
add_alias "rm" '"hello, world!"'
|
|
|
|
$alias_file | should exist
|
|
mock get_config { @(@{"rm" = "scoop-rm"}) }
|
|
|
|
rm_alias "rm"
|
|
$alias_file | should not exist
|
|
}
|
|
}
|
|
}
|