Files
Scoop/test/Scoop-Alias.Tests.ps1
T
Roy Ivy III 5200dc280e fix/improve Scoop-Alias and Scoop-Core tests
* 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
2015-08-25 22:45:21 -05:00

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
}
}
}