Completed Admin implementation.
This commit is contained in:
parent
c08ad81e51
commit
2b65189dde
|
@ -63,8 +63,6 @@ See the git log comments.
|
|||
|
||||
* More tests.
|
||||
|
||||
* Implement the rest of the Admin interface.
|
||||
|
||||
* Study src/main/ed/db/{dbcollection,dbcursor,db}.js and ByteEncoder.java in
|
||||
the Babble code. That's what I should be writing to.
|
||||
|
||||
|
|
|
@ -69,8 +69,15 @@ module XGen
|
|||
@db.query(DB::SYSTEM_PROFILE_COLLECTION, Query.new({})).to_a
|
||||
end
|
||||
|
||||
# Validate a named collection.
|
||||
# Validate a named collection by raising an exception if there is a
|
||||
# problem or returning +true+ if all is well.
|
||||
def validate_collection(name)
|
||||
doc = @db.db_command(:validate => name)
|
||||
raise "Error with validate command: #{doc.inspect}" unless @db.ok?(doc)
|
||||
result = doc['result']
|
||||
raise "Error with validation data: #{doc.inspect}" unless result.kind_of?(String)
|
||||
raise "Error: invalid collection #{name}: #{doc.inspect}" if result =~ /\b(exception|corrupt)\b/i
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -53,4 +53,8 @@ class AdminTest < Test::Unit::TestCase
|
|||
@admin.profiling_level = :off
|
||||
end
|
||||
|
||||
def test_validate_collection
|
||||
assert @admin.validate_collection(@coll.name)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue