Unit test - removed network creation

This commit is contained in:
Baptiste Donaux 2016-02-26 09:12:11 +01:00
parent 47631eb5de
commit b42cd85570
2 changed files with 2 additions and 20 deletions

View file

@ -54,21 +54,15 @@ load test_helpers
@test "[$TEST_FILE] separated containers (nginx + docker-gen + nginx.tmpl)" { @test "[$TEST_FILE] separated containers (nginx + docker-gen + nginx.tmpl)" {
docker_clean bats-nginx docker_clean bats-nginx
docker_clean bats-docker-gen docker_clean bats-docker-gen
docker_network_clean bats-docker-gen-network
# MAKE network
run docker network create bats-docker-gen-network
assert_success
# GIVEN a simple nginx container # GIVEN a simple nginx container
run docker run -d \ run docker run -d \
--name bats-nginx \ --name bats-nginx \
--net=bats-docker-gen-network \
-v /etc/nginx/conf.d/ \ -v /etc/nginx/conf.d/ \
-v /etc/nginx/certs/ \ -v /etc/nginx/certs/ \
nginx:latest nginx:latest
assert_success assert_success
run retry 5 1s docker run --net=bats-docker-gen-network appropriate/curl --silent --fail --head http://$(docker_ips bats-nginx)/ run retry 5 1s docker run appropriate/curl --silent --fail --head http://$(docker_ip bats-nginx)/
assert_output -l 0 $'HTTP/1.1 200 OK\r' assert_output -l 0 $'HTTP/1.1 200 OK\r'
# WHEN docker-gen runs on our docker host # WHEN docker-gen runs on our docker host
@ -120,4 +114,3 @@ function assert_nginxproxy_behaves {
run curl_container $container /data --header "Host: webFOO.bats" --head run curl_container $container /data --header "Host: webFOO.bats" --head
assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r' assert_output -l 0 $'HTTP/1.1 503 Service Temporarily Unavailable\r'
} }

View file

@ -8,22 +8,11 @@ function docker_clean {
sleep .25s sleep .25s
} }
# Removes network $1
function docker_network_clean {
docker network rm $1 &>/dev/null ||:
sleep .25s
}
# get the ip of docker container $1 # get the ip of docker container $1
function docker_ip { function docker_ip {
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1 docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1
} }
# get the ip of docker container $1
function docker_ips {
docker inspect --format '{{ range .NetworkSettings.Networks }}{{ .IPAddress }}{{ end }}' $1
}
# get the running state of container $1 # get the running state of container $1
# → true/false # → true/false
# fails if the container does not exist # fails if the container does not exist