diff --git a/Makefile b/Makefile index 4eaf98a..9c57706 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,11 @@ update-dependencies: docker pull python:3 docker pull rancher/socat-docker:latest docker pull appropriate/curl:latest - docker pull docker:1.7 + docker pull docker:1.9.1 test: - docker build -t jwilder/nginx-proxy:bats . + docker build -t dmp1ce/nginx-proxy-letsencrypt:bats . bats test + +test-clean: + ./test/cleanup_test_containers.sh diff --git a/test/README.md b/test/README.md index 721d436..c4fa6e8 100644 --- a/test/README.md +++ b/test/README.md @@ -3,12 +3,12 @@ Test suite This test suite is implemented on top of the [Bats](https://github.com/sstephenson/bats/blob/master/README.md) test framework. -It is intended to verify the correct behavior of the Docker image `jwilder/nginx-proxy:bats`. +It is intended to verify the correct behavior of the Docker image `dmp1ce/nginx-proxy-letsencrypt:bats`. Running the test suite ---------------------- Make sure you have Bats installed, then run: - docker build -t jwilder/nginx-proxy:bats . - bats test/ \ No newline at end of file + docker build -t jwilder/nginx-proxy-letsencrypt:bats . + bats test/ diff --git a/test/cleanup_test_containers.sh b/test/cleanup_test_containers.sh new file mode 100755 index 0000000..f4e0a3f --- /dev/null +++ b/test/cleanup_test_containers.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Remove "bats-*" containers +function teardown { + docker rm -f $(docker ps -aq -f name=bats-*) +} + +teardown diff --git a/test/docker.bats b/test/docker.bats index f4ec665..1de063d 100644 --- a/test/docker.bats +++ b/test/docker.bats @@ -62,7 +62,7 @@ load test_helpers -v /etc/nginx/certs/ \ nginx:latest assert_success - run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/ + run retry 5 1s docker run --rm appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/ assert_output -l 0 $'HTTP/1.1 200 OK\r' # WHEN docker-gen runs on our docker host @@ -114,4 +114,3 @@ function assert_nginxproxy_behaves { run curl_container $container /data --header "Host: webFOO.bats" --head assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r' } - diff --git a/test/lib/docker_helpers.bash b/test/lib/docker_helpers.bash index b5165af..fe09c49 100644 --- a/test/lib/docker_helpers.bash +++ b/test/lib/docker_helpers.bash @@ -56,5 +56,10 @@ function docker_tcp { --expose 2375 \ -v /var/run/docker.sock:/var/run/docker.sock \ rancher/socat-docker - docker run --link "$container_name:docker" docker:1.7 version + docker run --rm --link "$container_name:docker" docker:1.9.1 version } + +# Remove "bats-*" containers after each test +#function teardown { + #docker rm -f $(docker ps -aq -f name=bats-*) +#} diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 5890677..15d82bd 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -5,7 +5,7 @@ # set a few global variables -SUT_IMAGE=jwilder/nginx-proxy:bats +SUT_IMAGE=dmp1ce/nginx-proxy-letsencrypt:bats TEST_FILE=$(basename $BATS_TEST_FILENAME .bats) @@ -66,7 +66,7 @@ function curl_container { local -r container=$1 local -r path=$2 shift 2 - docker run appropriate/curl --silent \ + docker run --rm appropriate/curl --silent \ --connect-timeout 5 \ --max-time 20 \ "$@" \ @@ -128,7 +128,7 @@ function prepare_web_container { # THEN querying directly port works IFS=$' \t\n' # See https://github.com/sstephenson/bats/issues/89 for port in $ports; do - run retry 5 1s docker run appropriate/curl --silent --fail http://$(docker_ip $container_name):$port/data + run retry 5 1s docker run --rm appropriate/curl --silent --fail http://$(docker_ip $container_name):$port/data assert_output "answer from port $port" done }