2019-04-06 11:19:57 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
cd $(dirname "$BATS_TEST_DIRNAME")
|
|
|
|
}
|
|
|
|
|
|
|
|
cleaned_path() {
|
|
|
|
echo $PATH | tr ':' '\n' | grep -v "asdf" | tr '\n' ' '
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "exports ASDF_DIR" {
|
2021-11-18 03:05:27 -07:00
|
|
|
output=$(fish -c "
|
2019-04-06 11:19:57 -07:00
|
|
|
set -e asdf
|
|
|
|
set -e ASDF_DIR
|
|
|
|
set -e ASDF_DATA_DIR
|
|
|
|
set PATH $(cleaned_path)
|
|
|
|
|
2021-05-21 09:03:06 -07:00
|
|
|
. asdf.fish
|
2019-04-06 11:19:57 -07:00
|
|
|
echo \$ASDF_DIR
|
|
|
|
")
|
|
|
|
[ "$?" -eq 0 ]
|
2021-11-18 03:05:27 -07:00
|
|
|
[ "$output" != "" ]
|
2019-04-06 11:19:57 -07:00
|
|
|
}
|
|
|
|
|
2019-04-07 14:07:50 -07:00
|
|
|
@test "adds asdf dirs to PATH" {
|
2022-06-24 02:20:27 -07:00
|
|
|
result=$(fish -c "
|
|
|
|
set -e asdf
|
|
|
|
set -e ASDF_DIR
|
|
|
|
set -e ASDF_DATA_DIR
|
|
|
|
set PATH $(cleaned_path)
|
2019-04-07 14:07:50 -07:00
|
|
|
|
2022-06-24 02:20:27 -07:00
|
|
|
. (pwd)/asdf.fish # if the full path is not passed, status -f will return the relative path
|
|
|
|
echo \$PATH
|
2019-04-07 14:07:50 -07:00
|
|
|
")
|
2022-06-24 02:20:27 -07:00
|
|
|
[ "$?" -eq 0 ]
|
|
|
|
output=$(echo "$result" | grep "asdf")
|
|
|
|
[ "$output" != "" ]
|
2019-04-07 14:07:50 -07:00
|
|
|
}
|
2019-04-06 11:19:57 -07:00
|
|
|
|
|
|
|
@test "does not add paths to PATH more than once" {
|
|
|
|
result=$(fish -c "
|
|
|
|
set -e asdf
|
|
|
|
set -e ASDF_DIR
|
|
|
|
set -e ASDF_DATA_DIR
|
|
|
|
set PATH $(cleaned_path)
|
|
|
|
|
2021-05-21 09:03:06 -07:00
|
|
|
. asdf.fish
|
|
|
|
. asdf.fish
|
2019-04-06 11:19:57 -07:00
|
|
|
echo \$PATH
|
|
|
|
")
|
|
|
|
[ "$?" -eq 0 ]
|
2021-11-18 03:05:27 -07:00
|
|
|
output=$(echo $PATH | tr ':' '\n' | grep "asdf" | sort | uniq -d)
|
2019-04-06 11:19:57 -07:00
|
|
|
[ "$output" = "" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "defines the asdf function" {
|
|
|
|
output=$(fish -c "
|
|
|
|
set -e asdf
|
|
|
|
set -e ASDF_DIR
|
|
|
|
set PATH $(cleaned_path)
|
|
|
|
|
2021-05-21 09:03:06 -07:00
|
|
|
. asdf.fish
|
2019-04-06 11:19:57 -07:00
|
|
|
type asdf
|
|
|
|
")
|
2021-11-18 03:05:27 -07:00
|
|
|
[ "$?" -eq 0 ]
|
2019-04-06 11:19:57 -07:00
|
|
|
[[ "$output" =~ "is a function" ]]
|
|
|
|
}
|
2021-11-18 03:05:27 -07:00
|
|
|
|
|
|
|
@test "function calls asdf command" {
|
|
|
|
result=$(fish -c "
|
|
|
|
set -e asdf
|
|
|
|
set -x ASDF_DIR $(pwd)
|
|
|
|
set PATH $(cleaned_path)
|
|
|
|
|
|
|
|
. asdf.fish
|
|
|
|
asdf info
|
|
|
|
")
|
|
|
|
[ "$?" -eq 0 ]
|
|
|
|
output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:")
|
|
|
|
[ "$output" != "" ]
|
|
|
|
}
|