From 23bb6c2192d06752aa403531c71b40e24f9b9001 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Wed, 2 Dec 2009 16:43:30 -0500 Subject: [PATCH] minor: added tests for nonstandard port --- test/unit/connection_test.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/unit/connection_test.rb b/test/unit/connection_test.rb index 2a365d7..9ba1dd5 100644 --- a/test/unit/connection_test.rb +++ b/test/unit/connection_test.rb @@ -22,7 +22,7 @@ class ConnectionTest < Test::Unit::TestCase context "given a single node" do setup do TCPSocket.stubs(:new).returns(new_mock_socket) - @conn = Connection.new('localhost', 27107, :connect => false) + @conn = Connection.new('localhost', 27017, :connect => false) admin_db = new_mock_db admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}) @@ -45,6 +45,22 @@ class ConnectionTest < Test::Unit::TestCase end end + context "with a nonstandard port" do + setup do + TCPSocket.stubs(:new).returns(new_mock_socket) + @conn = Connection.new('255.255.255.255', 2500, :connect => false) + admin_db = new_mock_db + admin_db.expects(:command).returns({'ok' => 1, 'ismaster' => 1}) + @conn.expects(:[]).with('admin').returns(admin_db) + @conn.connect_to_master + end + + should "set localhost and port correctly" do + assert_equal '255.255.255.255', @conn.host + assert_equal 2500, @conn.port + end + end + context "Connection pooling: " do setup do TCPSocket.stubs(:new).returns(new_mock_socket)