9
PROJECT_DIR="$HOME/project"
10
mkdir -p "$PROJECT_DIR"
17
@test "uninstall_command should fail when no such version is installed" {
18
run asdf uninstall dummy 3.14
19
[ "$output" = "No such version" ]
23
@test "uninstall_command should remove the plugin with that version from asdf" {
24
run asdf install dummy 1.1.0
26
[ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
27
run asdf uninstall dummy 1.1.0
28
[ ! -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
31
@test "uninstall_command should invoke the plugin bin/uninstall if available" {
32
run asdf install dummy 1.1.0
34
mkdir -p "$ASDF_DIR/plugins/dummy/bin"
35
printf '%s\n' "echo custom uninstall" >"$ASDF_DIR/plugins/dummy/bin/uninstall"
36
chmod 755 "$ASDF_DIR/plugins/dummy/bin/uninstall"
37
run asdf uninstall dummy 1.1.0
38
[ "$output" = "custom uninstall" ]
42
@test "uninstall_command should remove the plugin shims if no other version is installed" {
43
run asdf install dummy 1.1.0
44
[ -f "$ASDF_DIR/shims/dummy" ]
45
run asdf uninstall dummy 1.1.0
46
[ ! -f "$ASDF_DIR/shims/dummy" ]
49
@test "uninstall_command should leave the plugin shims if other version is installed" {
50
run asdf install dummy 1.0.0
51
[ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]
53
run asdf install dummy 1.1.0
54
[ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
56
[ -f "$ASDF_DIR/shims/dummy" ]
57
run asdf uninstall dummy 1.0.0
58
[ -f "$ASDF_DIR/shims/dummy" ]
61
@test "uninstall_command should remove relevant asdf-plugin metadata" {
62
run asdf install dummy 1.0.0
63
[ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]
65
run asdf install dummy 1.1.0
66
[ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
68
run asdf uninstall dummy 1.0.0
69
run grep "asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy"
71
run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
75
@test "uninstall_command should not remove other unrelated shims" {
76
run asdf install dummy 1.0.0
77
[ -f "$ASDF_DIR/shims/dummy" ]
79
touch "$ASDF_DIR/shims/gummy"
80
[ -f "$ASDF_DIR/shims/gummy" ]
82
run asdf uninstall dummy 1.0.0
83
[ -f "$ASDF_DIR/shims/gummy" ]
86
@test "uninstall command executes configured pre hook" {
87
cat >"$HOME/.asdfrc" <<-'EOM'
88
pre_asdf_uninstall_dummy = echo will uninstall dummy $1
91
run asdf install dummy 1.0.0
92
run asdf uninstall dummy 1.0.0
93
[ "$output" = "will uninstall dummy 1.0.0" ]
96
@test "uninstall command executes configured post hook" {
97
cat >"$HOME/.asdfrc" <<-'EOM'
98
post_asdf_uninstall_dummy = echo removed dummy $1
101
run asdf install dummy 1.0.0
102
run asdf uninstall dummy 1.0.0
103
[ "$output" = "removed dummy 1.0.0" ]