From cc10cc185017f89ffc6f30821173c466d1720d51 Mon Sep 17 00:00:00 2001 From: Branden Cash Date: Mon, 12 Oct 2015 14:02:33 -0700 Subject: [PATCH] Attempt to write a test for the for the virtual host syntax (couldn't get the bats working locally in OS X...1) doesn't support -r argument for xargs 2) after hanging for a long time, existing tests gave me: -- output differs -- expected (1 lines): answer from port 80 90 actual (4 lines): Command "curl --silent --fail http://172.17.0.32:80 90/data" failed 5 times. Status: 7. Output: so obviously there is some other stuff in there that doesn't appear to play nice with OS X :( --- test/multiple-ports.bats | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/multiple-ports.bats b/test/multiple-ports.bats index a3c6fd0..9ba7bcf 100644 --- a/test/multiple-ports.bats +++ b/test/multiple-ports.bats @@ -39,6 +39,16 @@ function setup { } +@test "[$TEST_FILE] VIRTUAL_HOST proxy syntax" { + # GIVEN + prepare_web_container bats-web-${TEST_FILE}-2 "80 90" -e VIRTUAL_HOST=web.bats=>http:80,web1.bats=>http:90 + + # THEN + assert_response_is_from_port 80 web.bats + assert_response_is_from_port 90 web1.bats +} + + @test "[$TEST_FILE] single exposed port != 80" { # GIVEN prepare_web_container bats-web-${TEST_FILE}-3 1234 -e VIRTUAL_HOST=web.bats @@ -58,7 +68,8 @@ function setup { # $1 port we are expecting an response from function assert_response_is_from_port { local -r port=$1 - run curl_container $SUT_CONTAINER /data --header "Host: web.bats" + local -r host=${2:-web.bats} + run curl_container $SUT_CONTAINER /data --header "Host: $host" assert_output "answer from port $port" }