Completed Admin implementation.

This commit is contained in:
Jim Menard 2009-01-07 16:12:01 -05:00
parent c08ad81e51
commit 2b65189dde
3 changed files with 12 additions and 3 deletions

View File

@ -63,8 +63,6 @@ See the git log comments.
* More tests. * More tests.
* Implement the rest of the Admin interface.
* Study src/main/ed/db/{dbcollection,dbcursor,db}.js and ByteEncoder.java in * Study src/main/ed/db/{dbcollection,dbcursor,db}.js and ByteEncoder.java in
the Babble code. That's what I should be writing to. the Babble code. That's what I should be writing to.

View File

@ -69,8 +69,15 @@ module XGen
@db.query(DB::SYSTEM_PROFILE_COLLECTION, Query.new({})).to_a @db.query(DB::SYSTEM_PROFILE_COLLECTION, Query.new({})).to_a
end 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) 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
end end

View File

@ -53,4 +53,8 @@ class AdminTest < Test::Unit::TestCase
@admin.profiling_level = :off @admin.profiling_level = :off
end end
def test_validate_collection
assert @admin.validate_collection(@coll.name)
end
end end