Sha256: e8419d84a6d1bee2b7b78aa8d9575784880906a2471c7405d95ff93578599394

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

describe SolrWrapper::Client do
  subject { described_class.new('http://localhost:8983/solr/') }

  describe '#exists?' do
    it 'checks if a solrcloud collection exists' do
      stub_request(:get, 'http://localhost:8983/solr/admin/collections?action=LIST&wt=json').to_return(body: '{ "collections": ["x", "y", "z"]}')
      stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=a').to_return(body: '{ "status": { "a": {} } }')

      expect(subject.exists?('x')).to eq true
      expect(subject.exists?('a')).to eq false
    end

    it 'checks if a solr core exists' do
      stub_request(:get, 'http://localhost:8983/solr/admin/collections?action=LIST&wt=json').to_return(body: '{ "error": { "msg": "Solr instance is not running in SolrCloud mode."} }')

      stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=x').to_return(body: '{ "status": { "x": { "name": "x" } } }')
      stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=a').to_return(body: '{ "status": { "a": {} } }')

      expect(subject.exists?('x')).to eq true
      expect(subject.exists?('a')).to eq false
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
solr_wrapper-4.1.0 spec/lib/solr_wrapper/client_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/solr_wrapper-4.0.2/spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-4.0.2 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-4.0.1 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-4.0.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.1.3 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.1.2 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.1.1 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.1.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.0.2 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.0.1 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-3.0.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-2.2.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-2.1.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-2.0.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-1.2.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-1.1.0 spec/lib/solr_wrapper/client_spec.rb
solr_wrapper-1.0.0 spec/lib/solr_wrapper/client_spec.rb