Skip to content

Commit 326ab33

Browse files
authored
Merge pull request #3547 from projectblacklight/move-tests
Move tests for timeouts to the Solr::Repository spec
2 parents 70d84f2 + 848781d commit 326ab33

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

spec/models/blacklight/solr/repository_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@
144144
end.and_return('response' => { 'docs' => [] })
145145
subject.search(params: input_params)
146146
end
147+
148+
it "raises a Blacklight exception if RSolr can't connect to the Solr instance" do
149+
allow(repository.connection).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
150+
expect { subject.search(params: {}) }.to raise_exception(/Unable to connect to Solr instance/)
151+
end
152+
153+
it "raises a Blacklight exception if RSolr raises a timeout error connecting to Solr instance" do
154+
rsolr_timeout = RSolr::Error::Timeout.new(nil, nil)
155+
allow(rsolr_timeout).to receive(:to_s).and_return("mocked RSolr timeout")
156+
157+
allow(repository.connection).to receive(:send_and_receive).and_raise(rsolr_timeout)
158+
expect { subject.search(params: {}) }.to raise_exception(Blacklight::Exceptions::RepositoryTimeout, /Timeout connecting to Solr instance/)
159+
end
147160
end
148161

149162
describe "#build_solr_request" do

spec/services/blacklight/search_service_spec.rb

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@
1717
let(:user_params) { {} }
1818

1919
let(:blacklight_config) { CatalogController.blacklight_config.deep_copy }
20-
let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config.except(:adapter)) }
2120

2221
let(:all_docs_query) { '' }
2322
let(:no_docs_query) { 'zzzzzzzzzzzz' }
24-
# f[format][]=Book&f[language_facet][]=English
2523
let(:single_facet) { { format: 'Book' } }
2624

2725
before do
2826
allow(service).to receive(:repository).and_return(repository)
29-
service.repository.connection = blacklight_solr
3027
end
3128

3229
describe '#search_builder_class' do
@@ -51,6 +48,7 @@
5148
describe 'Search Results', :integration do
5249
describe 'for a sample query returning results' do
5350
let(:user_params) { { q: all_docs_query } }
51+
let(:blacklight_solr) { service.repository.connection }
5452

5553
it "uses the configured request handler" do
5654
allow(blacklight_config).to receive(:default_solr_params).and_return(qt: 'custom_request_handler')
@@ -372,18 +370,6 @@
372370
# TODO: maybe eventually check other types of solr requests
373371
# more like this
374372
# nearby on shelf
375-
it "raises a Blacklight exception if RSolr can't connect to the Solr instance" do
376-
allow(blacklight_solr).to receive(:send_and_receive).and_raise(Errno::ECONNREFUSED)
377-
expect { service.repository.search(params: {}) }.to raise_exception(/Unable to connect to Solr instance/)
378-
end
379-
380-
it "raises a Blacklight exception if RSolr raises a timeout error connecting to Solr instance" do
381-
rsolr_timeout = RSolr::Error::Timeout.new(nil, nil)
382-
allow(rsolr_timeout).to receive(:to_s).and_return("mocked RSolr timeout")
383-
384-
allow(blacklight_solr).to receive(:send_and_receive).and_raise(rsolr_timeout)
385-
expect { service.repository.search(params: {}) }.to raise_exception(Blacklight::Exceptions::RepositoryTimeout, /Timeout connecting to Solr instance/)
386-
end
387373

388374
describe "#previous_and_next_documents_for_search" do
389375
let(:user_params) { { q: '', per_page: 100 } }

0 commit comments

Comments
 (0)