• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / pdc_discovery / 5af13607-7741-41ac-b110-c94c8a3ee0f0

pending completion
5af13607-7741-41ac-b110-c94c8a3ee0f0

Pull #441

circleci

hectorcorrea
Better error handling
Pull Request #441: Indexing to a new collection

99 of 99 new or added lines in 3 files covered. (100.0%)

1816 of 2220 relevant lines covered (81.8%)

95.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.88
/spec/lib/dspace_indexer_spec.rb
1
# frozen_string_literal: true
2

3
RSpec.describe DspaceIndexer do
1✔
4
  describe 'indexing a community from DataSpace' do
1✔
5
    let(:community_fetch_with_expanded_metadata) { File.read(File.join(fixture_path, 'astrophysical_sciences.xml')) }
5✔
6
    let(:indexer) do
1✔
7
      described_class.new(community_fetch_with_expanded_metadata)
3✔
8
    end
9

10
    it "has a traject indexer" do
1✔
11
      expect(indexer.traject_indexer).to be_instance_of Traject::Indexer::NokogiriIndexer
1✔
12
    end
13

14
    context 'indexing to solr' do
1✔
15
      before do
1✔
16
        Blacklight.default_index.connection.delete_by_query("*:*")
2✔
17
        Blacklight.default_index.connection.commit
2✔
18
      end
19

20
      it "sends items to solr" do
1✔
21
        response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
1✔
22
        expect(response["response"]["numFound"]).to eq 0
1✔
23
        indexer.index
1✔
24
        response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
×
25
        expect(response["response"]["numFound"]).to eq 39
×
26
      end
27

28
      it "skips records already imported from PDC Describe" do
1✔
29
        # q=data_source_ssi:pdc_describe AND uri_ssim:http://arks.princeton.edu/ark:/88435/dsp017s75df84b
30
        solr_query_regex = /.*q=data_source_ssi\:pdc_describe\sAND\suri_ssim\:\"http\:\/\/arks.princeton.edu\/ark\:\/88435\/dsp017s75df84b\"/
1✔
31
        stub_request(:get, solr_query_regex).to_return(status: 200, body: '{"response":{"numFound":1}}', headers: {})
1✔
32

33
        response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
1✔
34
        expect(response["response"]["numFound"]).to eq 0
1✔
35
        indexer.index
1✔
36
        response = Blacklight.default_index.connection.get 'select', params: { q: '*:*' }
×
37
        expect(response["response"]["numFound"]).to eq 38
×
38
      end
39
    end
40

41
    context 'invoking from CLI' do
1✔
42
      let(:astrophysical_sciences_handle) { "88435/dsp015m60qr913" }
2✔
43
      let(:options) do
1✔
44
        {
45
          collection_handle: astrophysical_sciences_handle
1✔
46
        }
47
      end
48

49
      before do
1✔
50
        stub_request(:get, "https://dataspace-dev.princeton.edu/rest/collections/261/items?expand=all&limit=100&offset=0")
1✔
51
          .with(
52
            headers: {
53
              'Accept' => 'application/xml'
54
            }
55
          )
56
          .to_return(status: 200, body: community_fetch_with_expanded_metadata, headers: {})
57
      end
58

59
      it 'is easy to invoke from thor' do
1✔
60
        expect(described_class.index(options)).to be_instance_of(described_class)
1✔
61
      end
62
    end
63
  end
64
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc