Travis testing
This commit is contained in:
49
tests/bin/docker
Executable file
49
tests/bin/docker
Executable file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
case "$1" in
|
||||
stop)
|
||||
echo "testid"
|
||||
;;
|
||||
start)
|
||||
echo "testid"
|
||||
;;
|
||||
kill)
|
||||
echo "testid"
|
||||
;;
|
||||
run)
|
||||
echo "testid"
|
||||
;;
|
||||
rm)
|
||||
echo "testid"
|
||||
;;
|
||||
ps)
|
||||
if [[ $@ = *"no-trunc"* ]]; then
|
||||
echo "1479bbd60ade8a92617d2aeb4935bd3ff3179bd0fd71c22c3102c421f4bc221f"
|
||||
exit 0
|
||||
else
|
||||
echo "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES"
|
||||
echo "testid redis:3.0.3 \"/entrypoint.sh redi 5 minutes ago Up 5 minutes 6379/tcp dokku.redis.l"
|
||||
fi
|
||||
;;
|
||||
exec)
|
||||
echo "exec called with $@"
|
||||
;;
|
||||
inspect)
|
||||
if [[ $@ = *"IPAddress"* ]]; then
|
||||
echo "172.17.0.34"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# running
|
||||
echo "true"
|
||||
;;
|
||||
images)
|
||||
echo "REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE"
|
||||
echo "redis 3.0.3 9216d5a4eec8 13 days ago 109.3 MB"
|
||||
;;
|
||||
pull)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
|
||||
;;
|
||||
esac
|
||||
2
tests/bin/id
Executable file
2
tests/bin/id
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "dokku"
|
||||
2
tests/bin/redis-cli
Normal file
2
tests/bin/redis-cli
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
exit 0
|
||||
28
tests/service.bats
Normal file
28
tests/service.bats
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bats
|
||||
load test_helper
|
||||
|
||||
@test "(service) dokku" {
|
||||
dokku $PLUGIN_COMMAND_PREFIX:create l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:info l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:stop l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:stop l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:expose l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:restart l
|
||||
assert_success
|
||||
|
||||
dokku $PLUGIN_COMMAND_PREFIX:info l
|
||||
assert_success
|
||||
|
||||
dokku --force $PLUGIN_COMMAND_PREFIX:destroy l
|
||||
assert_success
|
||||
}
|
||||
15
tests/setup.sh
Normal file
15
tests/setup.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/test_helper.bash"
|
||||
|
||||
if [[ ! -d $DOKKU_ROOT ]]; then
|
||||
git clone https://github.com/progrium/dokku.git $DOKKU_ROOT > /dev/null
|
||||
fi
|
||||
|
||||
cd $DOKKU_ROOT
|
||||
echo "Dokku version $DOKKU_VERSION"
|
||||
git checkout $DOKKU_VERSION > /dev/null
|
||||
cd -
|
||||
|
||||
rm -rf $DOKKU_ROOT/plugins/service
|
||||
mkdir -p $DOKKU_ROOT/plugins/service
|
||||
find ./ -maxdepth 1 -type f -exec cp '{}' $DOKKU_ROOT/plugins/service \;
|
||||
58
tests/test_helper.bash
Normal file
58
tests/test_helper.bash
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
export DOKKU_QUIET_OUTPUT=1
|
||||
export DOKKU_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku"
|
||||
export DOKKU_VERSION=${DOKKU_VERSION:-"master"}
|
||||
export PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/bin:$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/dokku:$PATH"
|
||||
export PLUGIN_COMMAND_PREFIX="postgres"
|
||||
export PLUGIN_PATH="$DOKKU_ROOT/plugins"
|
||||
export PLUGIN_DATA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/fixtures"
|
||||
|
||||
mkdir -p $PLUGIN_DATA_ROOT
|
||||
|
||||
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"
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
export SERVICE=postgres
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
@test "(service) dokku" {
|
||||
dokku $SERVICE:create l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:info l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:stop l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:stop l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:expose l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:restart l
|
||||
assert_success
|
||||
|
||||
dokku $SERVICE:info l
|
||||
assert_success
|
||||
|
||||
dokku --force $SERVICE:destroy l
|
||||
assert_success
|
||||
}
|
||||
Reference in New Issue
Block a user