asdf

Форк
0
/
asdf_fish.bats 
91 строка · 1.7 Кб
1
#!/usr/bin/env bats
2
# shellcheck disable=SC2164
3

4
load test_helpers
5

6
setup() {
7
  cd "$(dirname "$BATS_TEST_DIRNAME")"
8

9
  if ! command -v fish &>/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
10
    skip "Fish is not installed"
11
  fi
12
}
13

14
cleaned_path() {
15
  echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ' '
16
}
17

18
@test "exports ASDF_DIR" {
19
  run fish --no-config -c "
20
    set -e asdf
21
    set -e ASDF_DIR
22
    set -e ASDF_DATA_DIR
23
    set PATH $(cleaned_path)
24

25
    . asdf.fish
26
    echo \$ASDF_DIR"
27

28
  [ "$status" -eq 0 ]
29
  [ "$output" != "" ]
30
}
31

32
@test "adds asdf dirs to PATH" {
33
  run fish --no-config -c "
34
    set -e asdf
35
    set -e ASDF_DIR
36
    set -e ASDF_DATA_DIR
37
    set PATH $(cleaned_path)
38

39
    . (pwd)/asdf.fish  # if the full path is not passed, status -f will return the relative path
40
    echo \$PATH"
41

42
  [ "$status" -eq 0 ]
43

44
  result=$(echo "$output" | grep "asdf")
45
  [ "$result" != "" ]
46
}
47

48
@test "does not add paths to PATH more than once" {
49
  run fish --no-config -c "
50
    set -e asdf
51
    set -e ASDF_DIR
52
    set -e ASDF_DATA_DIR
53
    set PATH $(cleaned_path)
54

55
    . asdf.fish
56
    . asdf.fish
57
    echo \$PATH"
58

59
  [ "$status" -eq 0 ]
60

61
  result=$(echo "$output" | tr ' ' '\n' | grep "asdf" | sort | uniq -d)
62
  [ "$result" = "" ]
63
}
64

65
@test "defines the asdf function" {
66
  run fish --no-config -c "
67
    set -e asdf
68
    set -e ASDF_DIR
69
    set PATH $(cleaned_path)
70

71
    . asdf.fish
72
    type asdf"
73

74
  [ "$status" -eq 0 ]
75
  [[ "$output" =~ "is a function" ]]
76
}
77

78
@test "function calls asdf command" {
79
  run fish --no-config -c "
80
    set -e asdf
81
    set -x ASDF_DIR $(pwd) # checkstyle-ignore
82
    set PATH $(cleaned_path)
83

84
    . asdf.fish
85
    asdf info"
86

87
  [ "$status" -eq 0 ]
88

89
  result=$(echo "$output" | grep "ASDF INSTALLED PLUGINS:")
90
  [ "$result" != "" ]
91
}
92

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

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

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

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