mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
commit
61b7e57154
71
test/asdf_sh.bats
Normal file
71
test/asdf_sh.bats
Normal file
@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helpers
|
||||
|
||||
# Helper function to handle sourcing of asdf.sh
|
||||
source_asdf_sh() {
|
||||
. $(dirname "$BATS_TEST_DIRNAME")/asdf.sh
|
||||
}
|
||||
|
||||
cleaned_path() {
|
||||
echo $PATH | tr ':' '\n' | grep -v "asdf" | tr '\n' ':'
|
||||
}
|
||||
|
||||
@test "exports ASDF_DIR" {
|
||||
result=$(
|
||||
unset -f asdf
|
||||
unset ASDF_DIR
|
||||
PATH=$(cleaned_path)
|
||||
|
||||
source_asdf_sh
|
||||
echo $ASDF_DIR
|
||||
)
|
||||
|
||||
output=$(echo "$result" | grep "asdf")
|
||||
[ "$?" -eq 0 ]
|
||||
[ "$output" != "" ]
|
||||
}
|
||||
|
||||
@test "adds asdf dirs to PATH" {
|
||||
result=$(
|
||||
unset -f asdf
|
||||
unset ASDF_DIR
|
||||
PATH=$(cleaned_path)
|
||||
|
||||
source_asdf_sh
|
||||
echo $PATH
|
||||
)
|
||||
|
||||
output=$(echo "$result" | grep "asdf")
|
||||
[ "$?" -eq 0 ]
|
||||
[ "$output" != "" ]
|
||||
}
|
||||
|
||||
@test "does not add paths to PATH more than once" {
|
||||
result=$(
|
||||
unset -f asdf
|
||||
unset ASDF_DIR
|
||||
PATH=$(cleaned_path)
|
||||
|
||||
source_asdf_sh
|
||||
source_asdf_sh
|
||||
echo $PATH
|
||||
)
|
||||
|
||||
output=$(echo $PATH | tr ':' '\n' | grep "asdf" | sort | uniq -d)
|
||||
[ "$?" -eq 0 ]
|
||||
[ "$output" = "" ]
|
||||
}
|
||||
|
||||
@test "defines the asdf function" {
|
||||
output=$(
|
||||
unset -f asdf
|
||||
unset ASDF_DIR
|
||||
PATH=$(cleaned_path)
|
||||
|
||||
source_asdf_sh
|
||||
type asdf
|
||||
)
|
||||
|
||||
[[ "$output" =~ "is a function" ]]
|
||||
}
|
Loading…
Reference in New Issue
Block a user