diff options
Diffstat (limited to 'test/exec')
-rw-r--r-- | test/exec/test_exec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index 4625b45..28ba24c 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -28,6 +28,13 @@ use Rack::ContentLength run proc { |env| [ 200, { 'Content-Type' => 'text/plain' }, [ "HI\\n" ] ] } EOS + SHOW_RACK_ENV = <<-EOS +use Rack::ContentLength +run proc { |env| + [ 200, { 'Content-Type' => 'text/plain' }, [ ENV['RACK_ENV'] ] ] +} + EOS + HELLO = <<-EOS class Hello def call(env) @@ -186,6 +193,46 @@ EOF assert_shutdown(pid) end + def test_rack_env_unset + File.open("config.ru", "wb") { |fp| fp.syswrite(SHOW_RACK_ENV) } + pid = fork { redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port") } } + results = retry_hit(["http://#{@addr}:#{@port}/"]) + assert_equal "development", results.first + assert_shutdown(pid) + end + + def test_rack_env_cli_set + File.open("config.ru", "wb") { |fp| fp.syswrite(SHOW_RACK_ENV) } + pid = fork { + redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port", "-Easdf") } + } + results = retry_hit(["http://#{@addr}:#{@port}/"]) + assert_equal "asdf", results.first + assert_shutdown(pid) + end + + def test_rack_env_ENV_set + File.open("config.ru", "wb") { |fp| fp.syswrite(SHOW_RACK_ENV) } + pid = fork { + ENV["RACK_ENV"] = "foobar" + redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port") } + } + results = retry_hit(["http://#{@addr}:#{@port}/"]) + assert_equal "foobar", results.first + assert_shutdown(pid) + end + + def test_rack_env_cli_override_ENV + File.open("config.ru", "wb") { |fp| fp.syswrite(SHOW_RACK_ENV) } + pid = fork { + ENV["RACK_ENV"] = "foobar" + redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port", "-Easdf") } + } + results = retry_hit(["http://#{@addr}:#{@port}/"]) + assert_equal "asdf", results.first + assert_shutdown(pid) + end + def test_ttin_ttou File.open("config.ru", "wb") { |fp| fp.syswrite(HI) } pid = fork { redirect_test_io { exec($unicorn_bin, "-l#@addr:#@port") } } |