asdf

Форк
0
/
uninstall_command.bats 
104 строки · 2.8 Кб
1
#!/usr/bin/env bats
2

3
load test_helpers
4

5
setup() {
6
  setup_asdf_dir
7
  install_dummy_plugin
8

9
  PROJECT_DIR="$HOME/project"
10
  mkdir -p "$PROJECT_DIR"
11
}
12

13
teardown() {
14
  clean_asdf_dir
15
}
16

17
@test "uninstall_command should fail when no such version is installed" {
18
  run asdf uninstall dummy 3.14
19
  [ "$output" = "No such version" ]
20
  [ "$status" -eq 1 ]
21
}
22

23
@test "uninstall_command should remove the plugin with that version from asdf" {
24
  run asdf install dummy 1.1.0
25
  [ "$status" -eq 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" ]
29
}
30

31
@test "uninstall_command should invoke the plugin bin/uninstall if available" {
32
  run asdf install dummy 1.1.0
33
  [ "$status" -eq 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" ]
39
  [ "$status" -eq 0 ]
40
}
41

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" ]
47
}
48

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" ]
52

53
  run asdf install dummy 1.1.0
54
  [ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
55

56
  [ -f "$ASDF_DIR/shims/dummy" ]
57
  run asdf uninstall dummy 1.0.0
58
  [ -f "$ASDF_DIR/shims/dummy" ]
59
}
60

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" ]
64

65
  run asdf install dummy 1.1.0
66
  [ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
67

68
  run asdf uninstall dummy 1.0.0
69
  run grep "asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy"
70
  [ "$status" -eq 0 ]
71
  run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
72
  [ "$status" -eq 1 ]
73
}
74

75
@test "uninstall_command should not remove other unrelated shims" {
76
  run asdf install dummy 1.0.0
77
  [ -f "$ASDF_DIR/shims/dummy" ]
78

79
  touch "$ASDF_DIR/shims/gummy"
80
  [ -f "$ASDF_DIR/shims/gummy" ]
81

82
  run asdf uninstall dummy 1.0.0
83
  [ -f "$ASDF_DIR/shims/gummy" ]
84
}
85

86
@test "uninstall command executes configured pre hook" {
87
  cat >"$HOME/.asdfrc" <<-'EOM'
88
pre_asdf_uninstall_dummy = echo will uninstall dummy $1
89
EOM
90

91
  run asdf install dummy 1.0.0
92
  run asdf uninstall dummy 1.0.0
93
  [ "$output" = "will uninstall dummy 1.0.0" ]
94
}
95

96
@test "uninstall command executes configured post hook" {
97
  cat >"$HOME/.asdfrc" <<-'EOM'
98
post_asdf_uninstall_dummy = echo removed dummy $1
99
EOM
100

101
  run asdf install dummy 1.0.0
102
  run asdf uninstall dummy 1.0.0
103
  [ "$output" = "removed dummy 1.0.0" ]
104
}
105

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.