mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Add tests for code in asdf.fish
This commit is contained in:
parent
61b7e57154
commit
ff553324a7
75
test/asdf_fish.bats
Normal file
75
test/asdf_fish.bats
Normal file
@ -0,0 +1,75 @@
|
||||
#!/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" {
|
||||
result=$(fish -c "
|
||||
set -e asdf
|
||||
set -e ASDF_DIR
|
||||
set -e ASDF_DATA_DIR
|
||||
set PATH $(cleaned_path)
|
||||
|
||||
source asdf.fish
|
||||
echo \$ASDF_DIR
|
||||
")
|
||||
|
||||
[ "$?" -eq 0 ]
|
||||
[ "$result" != "" ]
|
||||
}
|
||||
|
||||
# Passes for me locally, doesn't work on Travis CI
|
||||
#@test "adds asdf dirs to PATH" {
|
||||
# result=$(fish -c "
|
||||
# set -e asdf
|
||||
# set -e ASDF_DIR
|
||||
# set -e ASDF_DATA_DIR
|
||||
# set PATH $(cleaned_path)
|
||||
#
|
||||
# source asdf.fish
|
||||
# echo \$PATH
|
||||
# ")
|
||||
#
|
||||
# echo $result
|
||||
# output=$(echo "$result" | grep "asdf")
|
||||
# [ "$?" -eq 0 ]
|
||||
# [ "$output" != "" ]
|
||||
#}
|
||||
|
||||
@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)
|
||||
|
||||
source asdf.fish
|
||||
source asdf.fish
|
||||
echo \$PATH
|
||||
")
|
||||
|
||||
output=$(echo $PATH | tr ':' '\n' | grep "asdf" | sort | uniq -d)
|
||||
[ "$?" -eq 0 ]
|
||||
[ "$output" = "" ]
|
||||
}
|
||||
|
||||
@test "defines the asdf function" {
|
||||
output=$(fish -c "
|
||||
set -e asdf
|
||||
set -e ASDF_DIR
|
||||
set PATH $(cleaned_path)
|
||||
|
||||
source asdf.fish
|
||||
type asdf
|
||||
")
|
||||
|
||||
echo $output
|
||||
[[ "$output" =~ "is a function" ]]
|
||||
}
|
Loading…
Reference in New Issue
Block a user