asdf

Форк
0
/
remove_command.bats 
131 строка · 2.9 Кб
1
#!/usr/bin/env bats
2

3
load test_helpers
4

5
setup() {
6
  setup_asdf_dir
7
}
8

9
teardown() {
10
  clean_asdf_dir
11
}
12

13
@test "plugin_remove_command removes a plugin" {
14
  install_dummy_plugin
15

16
  run asdf plugin-remove "dummy"
17
  [ "$status" -eq 0 ]
18
  [ "$output" = "plugin-remove ${ASDF_DIR}/plugins/dummy" ]
19
}
20

21
@test "plugin_remove_command should exit with 1 when not passed any arguments" {
22
  run asdf plugin-remove
23
  [ "$status" -eq 1 ]
24
  [ "$output" = "No plugin given" ]
25
}
26

27
@test "plugin_remove_command should exit with 1 when passed invalid plugin name" {
28
  run asdf plugin-remove "does-not-exist"
29
  [ "$status" -eq 1 ]
30
  [ "$output" = "No such plugin: does-not-exist" ]
31
}
32

33
@test "plugin_remove_command should remove installed versions" {
34
  install_dummy_plugin
35
  run asdf install dummy 1.0
36
  [ "$status" -eq 0 ]
37
  [ -d "$ASDF_DIR/installs/dummy" ]
38

39
  run asdf plugin-remove dummy
40
  [ "$status" -eq 0 ]
41
  [ ! -d "$ASDF_DIR/installs/dummy" ]
42
}
43

44
@test "plugin_remove_command should also remove shims for that plugin" {
45
  install_dummy_plugin
46
  run asdf install dummy 1.0
47
  [ "$status" -eq 0 ]
48
  [ -f "$ASDF_DIR/shims/dummy" ]
49

50
  run asdf plugin-remove dummy
51
  [ "$status" -eq 0 ]
52
  [ ! -f "$ASDF_DIR/shims/dummy" ]
53
}
54

55
@test "plugin_remove_command should not remove unrelated shims" {
56
  install_dummy_plugin
57
  run asdf install dummy 1.0
58

59
  # make an unrelated shim
60
  echo "# asdf-plugin: gummy" >"$ASDF_DIR/shims/gummy"
61

62
  run asdf plugin-remove dummy
63
  [ "$status" -eq 0 ]
64

65
  # unrelated shim should exist
66
  [ -f "$ASDF_DIR/shims/gummy" ]
67
}
68

69
@test "plugin_remove_command executes pre-plugin-remove script" {
70
  install_dummy_plugin
71

72
  run asdf plugin-remove dummy
73

74
  [ "$output" = "plugin-remove ${ASDF_DIR}/plugins/dummy" ]
75
}
76

77
@test "plugin_remove_command executes configured pre hook (generic)" {
78
  install_dummy_plugin
79

80
  cat >"$HOME/.asdfrc" <<-'EOM'
81
pre_asdf_plugin_remove = echo REMOVE ${@}
82
EOM
83

84
  run asdf plugin-remove dummy
85

86
  local expected_output="REMOVE dummy
87
plugin-remove ${ASDF_DIR}/plugins/dummy"
88
  [ "$output" = "${expected_output}" ]
89
}
90

91
@test "plugin_remove_command executes configured pre hook (specific)" {
92
  install_dummy_plugin
93

94
  cat >"$HOME/.asdfrc" <<-'EOM'
95
pre_asdf_plugin_remove_dummy = echo REMOVE
96
EOM
97

98
  run asdf plugin-remove dummy
99

100
  local expected_output="REMOVE
101
plugin-remove ${ASDF_DIR}/plugins/dummy"
102
  [ "$output" = "${expected_output}" ]
103
}
104

105
@test "plugin_remove_command executes configured post hook (generic)" {
106
  install_dummy_plugin
107

108
  cat >"$HOME/.asdfrc" <<-'EOM'
109
post_asdf_plugin_remove = echo REMOVE ${@}
110
EOM
111

112
  run asdf plugin-remove dummy
113

114
  local expected_output="plugin-remove ${ASDF_DIR}/plugins/dummy
115
REMOVE dummy"
116
  [ "$output" = "${expected_output}" ]
117
}
118

119
@test "plugin_remove_command executes configured post hook (specific)" {
120
  install_dummy_plugin
121

122
  cat >"$HOME/.asdfrc" <<-'EOM'
123
post_asdf_plugin_remove_dummy = echo REMOVE
124
EOM
125

126
  run asdf plugin-remove dummy
127

128
  local expected_output="plugin-remove ${ASDF_DIR}/plugins/dummy
129
REMOVE"
130
  [ "$output" = "${expected_output}" ]
131
}
132

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

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

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

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