asdf

Форк
0
/
asdf_pwsh.bats 
96 строк · 2.1 Кб
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 pwsh &>/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
10
    skip "Powershell Core 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 pwsh -Command "
20
    function asdf() {} # checkstyle-ignore
21
    Remove-item Function:asdf
22
    \$Env:ASDF_DIR = ''
23
    \$Env:ASDF_DATA_DIR = ''
24
    \$Env:PATH = \"$(cleaned_path)\"
25

26
    . ./asdf.ps1
27
    Write-Output \"\$env:ASDF_DIR\""
28

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

33
@test "adds asdf dirs to PATH" {
34
  run pwsh -Command "
35
    function asdf() {} # checkstyle-ignore
36
    Remove-item Function:asdf
37
    \$Env:ASDF_DIR = ''
38
    \$Env:ASDF_DATA_DIR = ''
39
    \$Env:PATH = \"$(cleaned_path)\"
40

41
    . ./asdf.ps1
42
    Write-Output \$Env:PATH"
43

44
  [ "$status" -eq 0 ]
45
  result=$(echo "$output" | grep "asdf")
46
  [ "$result" != "" ]
47
}
48

49
@test "does not add paths to PATH more than once" {
50
  run pwsh -Command "
51
    function asdf() {} # checkstyle-ignore
52
    Remove-item Function:asdf
53
    \$Env:ASDF_DIR = ''
54
    \$Env:ASDF_DATA_DIR = ''
55
    \$Env:PATH = \"$(cleaned_path)\"
56

57
    . ./asdf.ps1
58
    . ./asdf.ps1
59
    Write-Output \$Env:PATH"
60

61
  [ "$status" -eq 0 ]
62

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

67
@test "defines the asdf function" {
68
  run pwsh -Command "
69
    function asdf() {} # checkstyle-ignore
70
    Remove-item Function:asdf
71
    \$Env:ASDF_DIR = ''
72
    \$Env:ASDF_DATA_DIR = ''
73
    \$Env:PATH = \"$(cleaned_path)\"
74

75
    ./ asdf.ps1
76
    \$(Get-Command -CommandType asdf).Name"
77

78
  [ "$status" -eq 0 ]
79
  [[ "$output" =~ "asdf" ]]
80
}
81

82
@test "function calls asdf command" {
83
  run pwsh -Command "
84
    function asdf() {} # checkstyle-ignore
85
    Remove-item Function:asdf
86
    \$Env:ASDF_DIR = ''
87
    \$Env:ASDF_DATA_DIR = ''
88
    \$Env:PATH = \"$(cleaned_path)\"
89

90
    . ./asdf.ps1
91
    asdf info"
92

93
  [ "$status" -eq 0 ]
94
  result=$(echo "$output" | grep "ASDF INSTALLED PLUGINS:")
95
  [ "$result" != "" ]
96
}
97

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

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

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

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