diff --git a/test/default-host.bats b/test/default-host.bats index 503bb9f..4e9d84e 100644 --- a/test/default-host.bats +++ b/test/default-host.bats @@ -4,7 +4,10 @@ load test_helpers function setup { # make sure to stop any web container before each test so we don't # have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set - docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2 + CIDS=( $(docker ps -q --filter "label=bats-type=web") ) + if [ ${#CIDS[@]} -gt 0 ]; then + docker stop ${CIDS[@]} >&2 + fi } diff --git a/test/multiple-hosts.bats b/test/multiple-hosts.bats index c5c5749..695aec1 100644 --- a/test/multiple-hosts.bats +++ b/test/multiple-hosts.bats @@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE} function setup { # make sure to stop any web container before each test so we don't # have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set - docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2 + CIDS=( $(docker ps -q --filter "label=bats-type=web") ) + if [ ${#CIDS[@]} -gt 0 ]; then + docker stop ${CIDS[@]} >&2 + fi } diff --git a/test/multiple-ports.bats b/test/multiple-ports.bats index a8ff314..a520571 100644 --- a/test/multiple-ports.bats +++ b/test/multiple-ports.bats @@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE} function setup { # make sure to stop any web container before each test so we don't # have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set - docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2 + CIDS=( $(docker ps -q --filter "label=bats-type=web") ) + if [ ${#CIDS[@]} -gt 0 ]; then + docker stop ${CIDS[@]} >&2 + fi } diff --git a/test/wildcard-hosts.bats b/test/wildcard-hosts.bats index 4e1484f..88ca1e7 100644 --- a/test/wildcard-hosts.bats +++ b/test/wildcard-hosts.bats @@ -5,7 +5,10 @@ SUT_CONTAINER=bats-nginx-proxy-${TEST_FILE} function setup { # make sure to stop any web container before each test so we don't # have any unexpected contaiener running with VIRTUAL_HOST or VIRUTAL_PORT set - docker ps -q --filter "label=bats-type=web" | xargs -r docker stop >&2 + CIDS=( $(docker ps -q --filter "label=bats-type=web") ) + if [ ${#CIDS[@]} -gt 0 ]; then + docker stop ${CIDS[@]} >&2 + fi }