Sha256: 3810341b26dac89599c99c85e2ca2f4d61db051ce637ab3c7d2ef2ec4aa9820d

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../test_helper'))

require 'einhorn'

class EinhornTest < Test::Unit::TestCase
  context "when sockifying" do
    teardown do
      Einhorn::State.sockets = {}
    end

    should "correctly parse srv: arguments" do
      cmd = ['foo', 'srv:1.2.3.4:123,llama,test', 'bar']
      Einhorn.expects(:bind).once.with('1.2.3.4', '123', ['llama', 'test']).returns(4)

      Einhorn.socketify!(cmd)

      assert_equal(['foo', '4', 'bar'], cmd)
    end

    should "correctly parse --opt=srv: arguments" do
      cmd = ['foo', '--opt=srv:1.2.3.4:456', 'baz']
      Einhorn.expects(:bind).once.with('1.2.3.4', '456', []).returns(5)

      Einhorn.socketify!(cmd)

      assert_equal(['foo', '--opt=5', 'baz'], cmd)
    end

    should "use the same fd number for the same server spec" do
      cmd = ['foo', '--opt=srv:1.2.3.4:8910', 'srv:1.2.3.4:8910']
      Einhorn.expects(:bind).once.with('1.2.3.4', '8910', []).returns(10)

      Einhorn.socketify!(cmd)

      assert_equal(['foo', '--opt=10', '10'], cmd)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
einhorn-0.4.2 test/unit/einhorn.rb
einhorn-0.4.1 test/unit/einhorn.rb
einhorn-0.4.0 test/unit/einhorn.rb
einhorn-0.3.2 test/unit/einhorn.rb
einhorn-0.3.1 test/unit/einhorn.rb
einhorn-0.3.0 test/unit/einhorn.rb