Bring test coverage back to 100 percent

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@498447 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-01-21 20:42:14 +00:00
parent d5bc3ec4ba
commit 80606b5f15
4 changed files with 29 additions and 2 deletions

View File

@ -29,7 +29,7 @@ module Solr
@header = @data['responseHeader']
raise "response should be a hash" unless @data.kind_of? Hash
raise "response header missing" unless @header.kind_of? Hash
rescue Exception => e
rescue SyntaxError => e
raise Solr::Exception.new("invalid ruby code: #{e}")
end
end

View File

@ -30,6 +30,16 @@ class DeleteTest < SolrMockBaseTestCase
response = conn.send(Solr::Request::Delete.new(:id => 123))
assert_equal true, response.ok?
end
def test_bad_delete_request
assert_raise(Solr::Exception) do
Solr::Request::Delete.new(:bogus => :param)
end
assert_raise(Solr::Exception) do
Solr::Request::Delete.new(:id => 529, :query => "id:529")
end
end
def test_bad_delete_response
conn = Solr::Connection.new 'http://localhost:9999/solr'

View File

@ -23,5 +23,17 @@ class ResponseTest < SolrMockBaseTestCase
assert_match 'invalid response xml', exception.to_s
end
end
def test_invalid_ruby
assert_raise(Solr::Exception) do
Solr::Response::Ruby.new(' {...')
end
end
def test_bogus_request_handling
assert_raise(Solr::Exception) do
Solr::Response::Base.make_response(Solr::Request::Select.new, "response data")
end
end
end

View File

@ -31,15 +31,20 @@ class StandardRequestTest < Test::Unit::TestCase
assert_raise(RuntimeError) do
Solr::Request::Standard.new(:query => "valid", :foo => "invalid")
end
assert_raise(RuntimeError) do
Solr::Request::Standard.new(:query => "valid", :operator => :bogus)
end
end
def test_common_params
request = Solr::Request::Standard.new(:query => 'query', :start => 10, :rows => 50,
:filter_queries => ['fq1', 'fq2'], :field_list => ['id','title','score'])
:filter_queries => ['fq1', 'fq2'], :field_list => ['id','title','score'], :operator => :and)
assert_equal 10, request.to_hash[:start]
assert_equal 50, request.to_hash[:rows]
assert_equal ['fq1','fq2'], request.to_hash[:fq]
assert_equal "id,title,score", request.to_hash[:fl]
assert_equal "AND", request.to_hash[:"q.op"]
end
def test_missing_params