self-contained "testing" infrastructure
This commit is contained in:
@@ -1,37 +1,6 @@
|
||||
#!/usr/bin/env bats
|
||||
export SERVICE=redis
|
||||
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
else echo "$*"
|
||||
fi
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
if [ "$status" -ne 0 ]; then
|
||||
flunk "command failed with exit status $status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_equal() {
|
||||
if [ "$1" != "$2" ]; then
|
||||
{ echo "expected: $1"
|
||||
echo "actual: $2"
|
||||
} | flunk
|
||||
fi
|
||||
}
|
||||
|
||||
assert_output() {
|
||||
local expected
|
||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||
else expected="$1"
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
load test_helper
|
||||
|
||||
@test "(service) dokku" {
|
||||
dokku $SERVICE:create l
|
||||
|
||||
56
tests/unit/test_helper.bash
Normal file
56
tests/unit/test_helper.bash
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export DOKKU_QUIET_OUTPUT=1
|
||||
export DOKKU_ROOT="tests/dokku"
|
||||
export DOKKU_VERSION=${DOKKU_VERSION:-"master"}
|
||||
export PATH="$(dirname $0)/../dokku:$PATH"
|
||||
export PLUGIN_PATH="$DOKKU_ROOT/plugins"
|
||||
export SERVICE=redis
|
||||
|
||||
flunk() {
|
||||
{ if [ "$#" -eq 0 ]; then cat -
|
||||
else echo "$*"
|
||||
fi
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
assert_equal() {
|
||||
if [ "$1" != "$2" ]; then
|
||||
{ echo "expected: $1"
|
||||
echo "actual: $2"
|
||||
} | flunk
|
||||
fi
|
||||
}
|
||||
|
||||
assert_exit_status() {
|
||||
assert_equal "$status" "$1"
|
||||
}
|
||||
|
||||
assert_success() {
|
||||
if [ "$status" -ne 0 ]; then
|
||||
flunk "command failed with exit status $status"
|
||||
elif [ "$#" -gt 0 ]; then
|
||||
assert_output "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_exists() {
|
||||
if [ ! -f "$1" ]; then
|
||||
flunk "expected file to exist: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_contains() {
|
||||
if [[ "$1" != *"$2"* ]]; then
|
||||
flunk "expected $2 to be in: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_output() {
|
||||
local expected
|
||||
if [ $# -eq 0 ]; then expected="$(cat -)"
|
||||
else expected="$1"
|
||||
fi
|
||||
assert_equal "$expected" "$output"
|
||||
}
|
||||
Reference in New Issue
Block a user