minor: make DB#validate_collection compatible with server v1.8 and v1.9.1
This commit is contained in:
parent
604d0f60ed
commit
f7e1feaeba
|
@ -602,7 +602,7 @@ module Mongo
|
||||||
if !ok?(doc)
|
if !ok?(doc)
|
||||||
raise MongoDBError, "Error with validate command: #{doc.inspect}"
|
raise MongoDBError, "Error with validate command: #{doc.inspect}"
|
||||||
end
|
end
|
||||||
if !doc['valid']
|
if (doc.has_key?('valid') && !doc['valid']) || (doc['result'] =~ /\b(exception|corrupt)\b/i)
|
||||||
raise MongoDBError, "Error: invalid collection #{name}: #{doc.inspect}"
|
raise MongoDBError, "Error: invalid collection #{name}: #{doc.inspect}"
|
||||||
end
|
end
|
||||||
doc
|
doc
|
||||||
|
|
|
@ -304,7 +304,11 @@ class DBTest < Test::Unit::TestCase
|
||||||
|
|
||||||
should "validate collection" do
|
should "validate collection" do
|
||||||
doc = @db.validate_collection(@coll.name)
|
doc = @db.validate_collection(@coll.name)
|
||||||
|
if @@version >= "1.9.1"
|
||||||
assert doc['valid']
|
assert doc['valid']
|
||||||
|
else
|
||||||
|
assert doc['result']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue