about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-11-04 15:38:59 -0800
committerEric Wong <normalperson@yhbt.net>2009-11-04 15:39:14 -0800
commitf6c63f950d033e28567fabfc47a57f938c4cbabf (patch)
tree6fdcbb60b5ef20e62122fa6705438aec3f570010 /test
parentae2afbcc7dbac0af3256aa8b46afebf6e309bac0 (diff)
downloadunicorn-f6c63f950d033e28567fabfc47a57f938c4cbabf.tar.gz
Prevent ourselves from breaking things in case applications
start depending on this.
Diffstat (limited to 'test')
-rw-r--r--test/exec/test_exec.rb47
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") } }