mirror of https://github.com/apache/lucene.git
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:
parent
d5bc3ec4ba
commit
80606b5f15
|
@ -29,7 +29,7 @@ module Solr
|
||||||
@header = @data['responseHeader']
|
@header = @data['responseHeader']
|
||||||
raise "response should be a hash" unless @data.kind_of? Hash
|
raise "response should be a hash" unless @data.kind_of? Hash
|
||||||
raise "response header missing" unless @header.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}")
|
raise Solr::Exception.new("invalid ruby code: #{e}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,6 +30,16 @@ class DeleteTest < SolrMockBaseTestCase
|
||||||
response = conn.send(Solr::Request::Delete.new(:id => 123))
|
response = conn.send(Solr::Request::Delete.new(:id => 123))
|
||||||
assert_equal true, response.ok?
|
assert_equal true, response.ok?
|
||||||
end
|
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
|
def test_bad_delete_response
|
||||||
conn = Solr::Connection.new 'http://localhost:9999/solr'
|
conn = Solr::Connection.new 'http://localhost:9999/solr'
|
||||||
|
|
|
@ -23,5 +23,17 @@ class ResponseTest < SolrMockBaseTestCase
|
||||||
assert_match 'invalid response xml', exception.to_s
|
assert_match 'invalid response xml', exception.to_s
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -31,15 +31,20 @@ class StandardRequestTest < Test::Unit::TestCase
|
||||||
assert_raise(RuntimeError) do
|
assert_raise(RuntimeError) do
|
||||||
Solr::Request::Standard.new(:query => "valid", :foo => "invalid")
|
Solr::Request::Standard.new(:query => "valid", :foo => "invalid")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
assert_raise(RuntimeError) do
|
||||||
|
Solr::Request::Standard.new(:query => "valid", :operator => :bogus)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_common_params
|
def test_common_params
|
||||||
request = Solr::Request::Standard.new(:query => 'query', :start => 10, :rows => 50,
|
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 10, request.to_hash[:start]
|
||||||
assert_equal 50, request.to_hash[:rows]
|
assert_equal 50, request.to_hash[:rows]
|
||||||
assert_equal ['fq1','fq2'], request.to_hash[:fq]
|
assert_equal ['fq1','fq2'], request.to_hash[:fq]
|
||||||
assert_equal "id,title,score", request.to_hash[:fl]
|
assert_equal "id,title,score", request.to_hash[:fl]
|
||||||
|
assert_equal "AND", request.to_hash[:"q.op"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_missing_params
|
def test_missing_params
|
||||||
|
|
Loading…
Reference in New Issue