summary refs log tree commit homepage
path: root/test/unit/test_droplet.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/test_droplet.rb')
-rw-r--r--test/unit/test_droplet.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/unit/test_droplet.rb b/test/unit/test_droplet.rb
new file mode 100644
index 0000000..73cf38c
--- /dev/null
+++ b/test/unit/test_droplet.rb
@@ -0,0 +1,28 @@
+require 'test/unit'
+require 'unicorn'
+
+class TestDroplet < Test::Unit::TestCase
+  def test_create_many_droplets
+    now = Time.now.to_i
+    tmp = (0..1024).map do |i|
+      droplet = Unicorn::Worker.new(i)
+      assert droplet.respond_to?(:tick)
+      assert_equal 0, droplet.tick
+      assert_equal(now, droplet.tick = now)
+      assert_equal now, droplet.tick
+      assert_equal(0, droplet.tick = 0)
+      assert_equal 0, droplet.tick
+    end
+  end
+
+  def test_shared_process
+    droplet = Unicorn::Worker.new(0)
+    _, status = Process.waitpid2(fork { droplet.tick += 1; exit!(0) })
+    assert status.success?, status.inspect
+    assert_equal 1, droplet.tick
+
+    _, status = Process.waitpid2(fork { droplet.tick += 1; exit!(0) })
+    assert status.success?, status.inspect
+    assert_equal 2, droplet.tick
+  end
+end