mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Follow bashstyle where possible
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
is_number() {
|
||||
local NUMBER=$1; local NUM_RE='^[0-9]+$'
|
||||
if [[ $NUMBER =~ $NUM_RE ]];then
|
||||
if [[ $NUMBER =~ $NUM_RE ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
||||
@@ -12,7 +12,7 @@ TEST_APP=my-cool-guy-test-app
|
||||
|
||||
# test functions
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
{ if [[ "$#" -eq 0 ]]; then cat -
|
||||
else echo "$*"
|
||||
fi
|
||||
}
|
||||
@@ -20,23 +20,23 @@ flunk() {
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
if [ "$status" -ne 0 ]; then
|
||||
if [[ "$status" -ne 0 ]]; then
|
||||
flunk "command failed with exit status $status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
elif [[ "$#" -gt 0 ]]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_failure() {
|
||||
if [ "$status" -eq 0 ]; then
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
flunk "expected failed exit status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
elif [[ "$#" -gt 0 ]]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_equal() {
|
||||
if [ "$1" != "$2" ]; then
|
||||
if [[ "$1" != "$2" ]]; then
|
||||
{ echo "expected: $1"
|
||||
echo "actual: $2"
|
||||
} | flunk
|
||||
@@ -45,34 +45,36 @@ assert_equal() {
|
||||
|
||||
assert_output() {
|
||||
local expected
|
||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||
else expected="$1"
|
||||
if [[ $# -eq 0 ]]; then
|
||||
expected="$(cat -)"
|
||||
else
|
||||
expected="$1"
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
|
||||
assert_line() {
|
||||
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||
if [[ "$1" -ge 0 ]] 2>/dev/null; then
|
||||
assert_equal "$2" "${lines[$1]}"
|
||||
else
|
||||
local line
|
||||
for line in "${lines[@]}"; do
|
||||
if [ "$line" = "$1" ]; then return 0; fi
|
||||
[[ "$line" = "$1" ]] && return 0
|
||||
done
|
||||
flunk "expected line \`$1'"
|
||||
fi
|
||||
}
|
||||
|
||||
refute_line() {
|
||||
if [ "$1" -ge 0 ] 2>/dev/null; then
|
||||
if [[ "$1" -ge 0 ]] 2>/dev/null; then
|
||||
local num_lines="${#lines[@]}"
|
||||
if [ "$1" -lt "$num_lines" ]; then
|
||||
if [[ "$1" -lt "$num_lines" ]]; then
|
||||
flunk "output has $num_lines lines"
|
||||
fi
|
||||
else
|
||||
local line
|
||||
for line in "${lines[@]}"; do
|
||||
if [ "$line" = "$1" ]; then
|
||||
if [[ "$line" = "$1" ]]; then
|
||||
flunk "expected to not find line \`$line'"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user