forked from ScoopInstaller/Scoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoop-Alias.Tests.ps1
55 lines (43 loc) · 1.16 KB
/
Scoop-Alias.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
. "$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 FileContentMatch ""
}
}
}
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
}
}
}