unicorn.git  about / heads / tags
Rack HTTP server for Unix and fast clients
blob 81ad82b03bb7436cfd2350fd31e85dd44113f2e6 815 bytes (raw)
$ git show no-kgio-wip:test/unit/test_droplet.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
require 'test/unit'
require 'unicorn'

class TestDroplet < Test::Unit::TestCase
  def test_create_many_droplets
    now = Time.now.to_i
    (0..1024).each 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

git clone https://yhbt.net/unicorn.git