asdf

Форк
0
/
asdf_sh.bats 
97 строк · 1.6 Кб
1
#!/usr/bin/env bats
2

3
load test_helpers
4

5
# Helper function to handle sourcing of asdf.sh
6
source_asdf_sh() {
7
  . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh"
8
}
9

10
cleaned_path() {
11
  echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ':'
12
}
13

14
@test "exports ASDF_DIR" {
15
  output=$(
16
    unset -f asdf
17
    unset ASDF_DIR
18
    PATH=$(cleaned_path)
19

20
    source_asdf_sh
21
    echo "$ASDF_DIR"
22
  )
23

24
  result=$(echo "$output" | grep "asdf")
25
  [ "$result" != "" ]
26
}
27

28
@test "does not error if nounset is enabled" {
29
  output=$(
30
    unset -f asdf
31
    unset ASDF_DIR
32
    PATH=$(cleaned_path)
33
    set -o nounset
34

35
    source_asdf_sh
36
    echo "$ASDF_DIR"
37
  )
38

39
  result=$(echo "$output" | grep "asdf")
40
  [ "$result" != "" ]
41
}
42

43
@test "adds asdf dirs to PATH" {
44
  output=$(
45
    unset -f asdf
46
    unset ASDF_DIR
47
    PATH=$(cleaned_path)
48

49
    source_asdf_sh
50
    echo "$PATH"
51
  )
52

53
  result=$(echo "$output" | grep "asdf")
54
  [ "$result" != "" ]
55
}
56

57
@test "does not add paths to PATH more than once" {
58
  output=$(
59
    unset -f asdf
60
    unset ASDF_DIR
61
    PATH=$(cleaned_path)
62

63
    source_asdf_sh
64
    source_asdf_sh
65
    echo "$PATH"
66
  )
67

68
  result=$(echo "$output" | tr ':' '\n' | grep "asdf" | sort | uniq -d)
69
  [ "$result" = "" ]
70
}
71

72
@test "defines the asdf function" {
73
  output=$(
74
    unset -f asdf
75
    unset ASDF_DIR
76
    PATH=$(cleaned_path)
77

78
    source_asdf_sh
79
    type asdf
80
  )
81

82
  [[ "$output" =~ "is a function" ]]
83
}
84

85
@test "function calls asdf command" {
86
  result=$(
87
    unset -f asdf
88
    ASDF_DIR=$PWD
89
    PATH=$(cleaned_path)
90

91
    source_asdf_sh
92
    asdf info
93
  )
94

95
  output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:")
96
  [ "$output" != "" ]
97
}
98

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

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

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

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