Skip to content
Browse files

tests: use environment to configure servers

  • Loading branch information...
1 parent ad80420 commit ba7e840d05c912b959d9ff81be70297bd164172c @4z3 committed Aug 17, 2011
Showing with 18 additions and 7 deletions.
  1. +6 −2 tests/test-file-server.sh
  2. +12 −5 tests/test-proxy-server.sh
View
8 tests/test-file-server.sh
@@ -1,5 +1,11 @@
#! /bin/sh
+export host=127.0.0.1
+export port=1337
+export handler=file
+
+url=http://$host:$port/
+
run_tests() {
content='Hello, world!'
content_type='text/plain-zzz'
@@ -66,8 +72,6 @@ atexit="${atexit+$atexit;}rm -f $temp1 $temp2"
trap "$atexit" EXIT INT
-url=http://127.0.0.1:1337/
-
start_server() {
node . &
atexit="${atexit+$atexit;}kill -0 $! && kill $!"
View
17 tests/test-proxy-server.sh
@@ -1,21 +1,28 @@
#! /bin/sh
-fe_port=1337; fe_url="http://127.0.0.1:$fe_port"
-be_port=1338; be_url="http://127.0.0.1:$be_port"
+export host=127.0.0.1
+export port=1337
+export handler=proxy
+
+url=http://$host:$port
+
+be_host=$host
+be_port=1338
+be_url=http://$be_host:$be_port
run_tests() {
p_content="{\"baseURL\":\"$be_url\"}"
p_type='application/vnd.deserver.proxy-v0+json'
begin 'PUT /p (nonexistent proxy resource)'
- PUT "$fe_url/p" "$p_content" "$p_type"
+ PUT "$url/p" "$p_content" "$p_type"
assert status_code 201
assert content ''
end
f=tests/data/foo.txt
begin "GET /p/$f"
- GET "$fe_url/p/$f" "$p_content" "$p_type"
+ GET "$url/p/$f" "$p_content" "$p_type"
assert status_code 200
assert content "`cat $f`"
end
@@ -38,7 +45,7 @@ start_server() {
node . &
atexit="${atexit+$atexit;}kill -0 $! && kill $!"
trap "$atexit" EXIT INT
- while ! curl -s -X HEAD "$fe_url"; do
+ while ! curl -s -X HEAD "$url"; do
sleep 0.05
done

0 comments on commit ba7e840

Please sign in to comment.
Something went wrong with that request. Please try again.