Sha256: f920c8ec7219fe06584e1884ab55cfd5bb54f7bd9ffb4eeecf2248a542195ef5

Contents?: true

Size: 1.17 KB

Versions: 34

Compression:

Stored size: 1.17 KB

Contents

require 'test/unit'
require 'securerandom'
require 'rubygems'
require_relative "#{File.dirname(__FILE__)}/../../lib/pigato.rb"

class BaseTest < Test::Unit::TestCase

  def setup
    bhost = 'tcp://localhost:55555'
    @client = Pigato::Client.new(bhost, { :autostart => true })
    @ns = SecureRandom.uuid
    
    @wks = []    
    @wks << fork do
      worker = Pigato::Worker.new(bhost, @ns + 'echo')

      loop do
        reply = nil
        request = worker.recv reply
        worker.reply request
      end
    end

    @wks << fork do
      worker = Pigato::Worker.new(bhost, @ns + 'empty')

      loop do
        reply = nil
        request = worker.recv reply
        worker.reply nil
      end
    end
  end

  def teardown
    @wks.each do |wk|
      Process.kill 9, wk
      Process.wait wk
    end
  end

  def test0
    assert_equal('hello', @client.request(@ns + 'echo', 'hello'))
    h = { 'hello' => 'world' }
    assert_equal(h, @client.request(@ns + 'echo', h))
    a = ['a', 1, false]
    assert_equal(a, @client.request(@ns + 'echo', a))
    
    assert_equal(1, @client.request(@ns + 'echo', 1))
    
    assert_equal(nil, @client.request(@ns + 'empty', nil))
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
pigato-0.5.1 tests/test_base.rb
pigato-0.5.0 tests/test_base.rb
pigato-0.4.9 tests/test_base.rb
pigato-0.4.8 tests/test_base.rb
pigato-0.4.7 tests/test_base.rb
pigato-0.4.6 tests/test_base.rb
pigato-0.4.5 tests/test_base.rb
pigato-0.4.4 tests/test_base.rb
pigato-0.4.3 tests/test_base.rb
pigato-0.4.2 tests/test_base.rb
pigato-0.4.1 tests/test_base.rb
pigato-0.4.0 tests/test_base.rb
pigato-0.3.1 tests/test_base.rb
pigato-0.3.0 tests/test_base.rb
pigato-0.2.27 tests/test_base.rb
pigato-0.2.26 tests/test_base.rb
pigato-0.2.25 tests/test_base.rb
pigato-0.2.23 tests/test_base.rb
pigato-0.2.22 tests/test_base.rb
pigato-0.2.21 tests/test_base.rb