minor: allow oplog. collection
This commit is contained in:
parent
4550389480
commit
f0766c9d2e
|
@ -33,8 +33,8 @@ module Mongo
|
|||
if name.empty? or name.include? ".."
|
||||
raise InvalidName, "collection names cannot be empty"
|
||||
end
|
||||
if name.include? "$" and not name.match(/^\$cmd/)
|
||||
raise InvalidName, "collection names must not contain '$'"
|
||||
if name.include? "$"
|
||||
raise InvalidName, "collection names must not contain '$'" unless name =~ /((^\$cmd)|(oplog\.\$main))/
|
||||
end
|
||||
if name.match(/^\./) or name.match(/\.$/)
|
||||
raise InvalidName, "collection names must not start or end with '.'"
|
||||
|
|
|
@ -26,11 +26,20 @@ class TestCollection < Test::Unit::TestCase
|
|||
assert @coll.pk_factory.is_a?(Object)
|
||||
end
|
||||
|
||||
def test_collection
|
||||
def test_valid_names
|
||||
assert_raise InvalidName do
|
||||
@@db["te$t"]
|
||||
end
|
||||
|
||||
assert_raise InvalidName do
|
||||
@@db['$main']
|
||||
end
|
||||
|
||||
assert @@db['$cmd']
|
||||
assert @@db['oplog.$main']
|
||||
end
|
||||
|
||||
def test_collection
|
||||
assert_kind_of Collection, @@db["test"]
|
||||
assert_equal @@db["test"].name(), @@db.collection("test").name()
|
||||
assert_equal @@db["test"].name(), @@db[:test].name()
|
||||
|
|
Loading…
Reference in New Issue