Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

RUBY-438 Moving w tests for replica sets, changing support method sli…

…ghtly, starting to support symbols
  • Loading branch information...
commit eb9e5a2f4c4db80a52da5d1dc00a44571b1ef990 1 parent e35e43c
@estolfo estolfo authored
View
5 lib/mongo/util/support.rb
@@ -114,9 +114,8 @@ def format_order_clause(order)
end
end
- def str_is_i?(str)
- raise TypeError, "must be called with a string" unless str.class == String
- return !!(str =~ /^[0-9]+$/)
+ def is_i?(value)
+ return !!(value =~ /^\d+$/)
end
# Determine if a database command has succeeded by
View
2  lib/mongo/util/uri_parser.rb
@@ -81,7 +81,7 @@ class URIParser
:replicaset => lambda {|arg| arg},
:slaveok => lambda {|arg| arg == 'true' ? true : false},
:safe => lambda {|arg| arg == 'true' ? true : false},
- :w => lambda {|arg| Mongo::Support.str_is_i?(arg) ? arg.to_i : arg.to_s },
+ :w => lambda {|arg| Mongo::Support.is_i?(arg) ? arg.to_i : arg.to_sym },
:wtimeout => lambda {|arg| arg.to_i},
:fsync => lambda {|arg| arg == 'true' ? true : false},
:journal => lambda {|arg| arg == 'true' ? true : false},
View
7 lib/mongo/util/write_concern.rb
@@ -60,7 +60,12 @@ def get_write_concern(opts, parent=nil)
end
def self.gle?(write_concern)
- (write_concern[:w].is_a? String) || write_concern[:w] > 0 || write_concern[:j] || write_concern[:fsync] || write_concern[:wtimeout]
+ #(write_concern[:w].is_a? Symbol) ||
+ (write_concern[:w].is_a? String) ||
+ write_concern[:w] > 0 ||
+ write_concern[:j] ||
+ write_concern[:fsync] ||
+ write_concern[:wtimeout]
end
end
View
36 test/functional/write_concern_test.rb
@@ -67,42 +67,6 @@ class WriteConcernTest < Test::Unit::TestCase
end
end
- context "Write concern options" do
- def setup
- ensure_cluster(:rs)
- @client = MongoReplicaSetClient.new @rs.repl_set_seeds
- @db = @client.db(MONGO_TEST_DB)
- @db.drop_collection("test-sets")
- @coll = @db.collection("test-sets")
- end
-
- def teardown
- @db.drop_collection("test-sets")
- @client.close if @conn
- end
-
- def self.shutdown
- @@cluster.stop
- @@cluster.clobber
- end
-
- should "accept a string 'majority' for write concern in a replica set" do
- @coll.insert({:a => 1}, :w => "majority")
- end
-
- should "accept a string specificying a getLastErrorMode for write concern in a replica set" do
- assert_raise Mongo::OperationFailure do
- @coll.insert({:b => 2}, :w => "test-tag")
- end
- end
-
- should "accept an integer write concern for a replica set" do
- @coll.insert({:d => 4}, :w => 2 )
- end
-
- end
-
-
context "Write concern in gridfs" do
setup do
@db = standard_connection.db(MONGO_TEST_DB)
View
7 test/replica_set/replication_ack_test.rb
@@ -36,6 +36,9 @@ def test_safe_mode_with_w_failure
assert_raise_error OperationFailure, "timeout" do
@col.remove({:foo => 2}, :w => 4, :wtimeout => 1, :fsync => true)
end
+ assert_raise_error OperationFailure do
+ @col.insert({:foo => 3}, :w => "test-tag")
+ end
end
def test_safe_mode_replication_ack
@@ -47,6 +50,10 @@ def test_safe_mode_replication_ack
assert @col.update({:baz => "bar"}, {:baz => "foo"}, :w => 3, :wtimeout => 5000)
assert @slave1[MONGO_TEST_DB]["test-sets"].find_one({:baz => "foo"})
+ assert @col.insert({:foo => "bar"}, :w => "majority")
+
+ #assert @col.insert({:bar => "baz"}, :w => :majority)
+
assert @col.remove({}, :w => 3, :wtimeout => 5000)
assert_equal 0, @slave1[MONGO_TEST_DB]["test-sets"].count
end
Please sign in to comment.
Something went wrong with that request. Please try again.