minor: fix for format change is result for 1.9.1 'validate' command.
This commit is contained in:
parent
135bebd9ab
commit
cb54c6b295
@ -595,11 +595,16 @@ module Mongo
|
||||
# @raise [MongoDBError] if the command fails or there's a problem with the validation
|
||||
# data, or if the collection is invalid.
|
||||
def validate_collection(name)
|
||||
doc = command({:validate => name}, :check_response => false)
|
||||
raise MongoDBError, "Error with validate command: #{doc.inspect}" unless ok?(doc)
|
||||
result = doc['result']
|
||||
raise MongoDBError, "Error with validation data: #{doc.inspect}" unless result.kind_of?(String)
|
||||
raise MongoDBError, "Error: invalid collection #{name}: #{doc.inspect}" if result =~ /\b(exception|corrupt)\b/i
|
||||
cmd = BSON::OrderedHash.new
|
||||
cmd[:validate] = name
|
||||
cmd[:full] = true
|
||||
doc = command(cmd, :check_response => false)
|
||||
if !ok?(doc)
|
||||
raise MongoDBError, "Error with validate command: #{doc.inspect}"
|
||||
end
|
||||
if !doc['valid']
|
||||
raise MongoDBError, "Error: invalid collection #{name}: #{doc.inspect}"
|
||||
end
|
||||
doc
|
||||
end
|
||||
|
||||
|
@ -298,17 +298,13 @@ class DBTest < Test::Unit::TestCase
|
||||
assert_kind_of Array, info
|
||||
assert info.length >= 1
|
||||
first = info.first
|
||||
assert_kind_of String, first['info']
|
||||
assert_kind_of Time, first['ts']
|
||||
assert_kind_of Numeric, first['millis']
|
||||
end
|
||||
|
||||
should "validate collection" do
|
||||
doc = @db.validate_collection(@coll.name)
|
||||
assert_not_nil doc
|
||||
result = doc['result']
|
||||
assert_not_nil result
|
||||
assert_match(/firstExtent/, result)
|
||||
assert doc['valid']
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user