1
0
mirror of https://github.com/jcwimer/docker-swarm-autoscaler synced 2026-05-17 18:25:06 +00:00

First release with tests

This commit is contained in:
2019-12-18 13:35:37 -05:00
parent 4c4c972dbd
commit 0f2424221a
15 changed files with 797 additions and 44 deletions

35
tests/run-tests.sh Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -ex
function main {
build-image
run-ruby-tests
}
function cd-to-top-of-repo {
cd "$(git rev-parse --show-toplevel)"
}
function build-image {
cd-to-top-of-repo
docker build -t docker-swarm-autoscaler-tests ./tests
}
function run-ruby-tests {
cd-to-top-of-repo
echo 'INFO: Running rspec unit tests...'
local -r container_id=$(
docker create --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
docker-swarm-autoscaler-tests \
bash -c "cd /root/tests && \
bundle exec rake spec"
)
docker cp . "${container_id}:/root/"
trap "docker rm ${container_id}" SIGHUP
docker start --attach --interactive "${container_id}"
}
[[ "${0}" == "${BASH_SOURCE[0]}" ]] && main "${@}"