Removed assert_link_exist function
This is now provided by the used version of bats-file.pull/1559/head
parent
d6e559f424
commit
e9467825ec
|
|
@ -85,48 +85,3 @@ teardown() {
|
|||
rm -rf "${BASH_IT_TEST_DIR}"
|
||||
temp_del "${TEST_TEMP_DIR}"
|
||||
}
|
||||
|
||||
# Fail and display path of the link if it does not exist. Also fails
|
||||
# if the path exists, but is not a link.
|
||||
# This function is the logical complement of `assert_file_not_exist'.
|
||||
# There is no dedicated function for checking that a link does not exist.
|
||||
#
|
||||
# Globals:
|
||||
# BATSLIB_FILE_PATH_REM
|
||||
# BATSLIB_FILE_PATH_ADD
|
||||
# Arguments:
|
||||
# $1 - path
|
||||
# Returns:
|
||||
# 0 - link exists and is a link
|
||||
# 1 - otherwise
|
||||
# Outputs:
|
||||
# STDERR - details, on failure
|
||||
assert_link_exist() {
|
||||
local -r file="$1"
|
||||
local -r target="$2"
|
||||
if [[ ! -L "$file" ]]; then
|
||||
local -r rem="$BATSLIB_FILE_PATH_REM"
|
||||
local -r add="$BATSLIB_FILE_PATH_ADD"
|
||||
if [[ -e "$file" ]]; then
|
||||
batslib_print_kv_single 4 'path' "${file/$rem/$add}" \
|
||||
| batslib_decorate 'exists, but is not a link' \
|
||||
| fail
|
||||
else
|
||||
batslib_print_kv_single 4 'path' "${file/$rem/$add}" \
|
||||
| batslib_decorate 'link does not exist' \
|
||||
| fail
|
||||
fi
|
||||
else
|
||||
if [ -n "$target" ]; then
|
||||
local link_target=''
|
||||
link_target=$(readlink "$file")
|
||||
if [[ "$link_target" != "$target" ]]; then
|
||||
batslib_print_kv_single_or_multi 8 'path' "${file/$rem/$add}" \
|
||||
'expected' "$target" \
|
||||
'actual' "$link_target" \
|
||||
| batslib_decorate 'link exists, but does not point to target file' \
|
||||
| fail
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue