|
5 | 5 | require 'spec_helper' |
6 | 6 |
|
7 | 7 | RSpec.describe GeoCombine::Harvester do |
8 | | - subject(:harvester) { described_class.new(ogm_path: 'spec/fixtures/indexing', schema_version: '1.0') } |
| 8 | + subject(:harvester) { described_class.new(ogm_path: 'spec/fixtures/indexing', logger: logger) } |
9 | 9 |
|
10 | 10 | let(:logger) { instance_double(Logger, warn: nil, info: nil, error: nil, debug: nil) } |
11 | 11 | let(:repo_name) { 'my-institution' } |
|
14 | 14 | let(:stub_repo) { instance_double(Git::Base) } |
15 | 15 | let(:stub_gh_api) do |
16 | 16 | [ |
17 | | - { name: repo_name, size: 100 }, |
18 | | - { name: 'another-institution', size: 100 }, |
19 | | - { name: 'outdated-institution', size: 100, archived: true }, # archived |
20 | | - { name: 'aardvark', size: 300 }, # on denylist |
21 | | - { name: 'empty', size: 0 } # no data |
| 17 | + { name: repo_name, size: 100, custom_properties: { supported_schemas: ['Aardvark'] } }, |
| 18 | + { name: 'another-institution', size: 100, custom_properties: { supported_schemas: ['Aardvark', '1.0'] } }, # multiple schemas |
| 19 | + { name: 'v1-institution', size: 300, custom_properties: { supported_schemas: ['1.0'] } }, # schema mismatch |
| 20 | + { name: 'outdated-institution', size: 100, custom_properties: { supported_schemas: ['Aardvark'] }, archived: true }, # archived |
| 21 | + { name: 'empty', size: 0, custom_properties: { supported_schemas: ['Aardvark'] } }, # no data |
| 22 | + { name: 'tool', size: 50 } # not a metadata repository |
22 | 23 | ] |
23 | 24 | end |
24 | 25 |
|
|
42 | 43 | describe '#docs_to_index' do |
43 | 44 | it 'yields each JSON record with its path, skipping layers.JSON' do |
44 | 45 | expect { |b| harvester.docs_to_index(&b) }.to yield_successive_args( |
45 | | - [JSON.parse(File.read('spec/fixtures/indexing/basic_geoblacklight.json')), 'spec/fixtures/indexing/basic_geoblacklight.json'], |
46 | | - [JSON.parse(File.read('spec/fixtures/indexing/geoblacklight.json')), 'spec/fixtures/indexing/geoblacklight.json'] |
| 46 | + [JSON.parse(File.read('spec/fixtures/indexing/aardvark.json')), 'spec/fixtures/indexing/aardvark.json'] |
47 | 47 | ) |
48 | 48 | end |
49 | 49 |
|
50 | | - it 'skips records with a different schema version' do |
51 | | - harvester = described_class.new(ogm_path: 'spec/fixtures/indexing/', schema_version: 'Aardvark', logger:) |
| 50 | + it 'can yield JSON records for a different schema version' do |
| 51 | + harvester = described_class.new(ogm_path: 'spec/fixtures/indexing/', schema_version: '1.0', logger:) |
52 | 52 | expect { |b| harvester.docs_to_index(&b) }.to yield_successive_args( |
53 | | - [JSON.parse(File.read('spec/fixtures/indexing/aardvark.json')), 'spec/fixtures/indexing/aardvark.json'] |
| 53 | + [JSON.parse(File.read('spec/fixtures/indexing/basic_geoblacklight.json')), 'spec/fixtures/indexing/basic_geoblacklight.json'], |
| 54 | + [JSON.parse(File.read('spec/fixtures/indexing/geoblacklight.json')), 'spec/fixtures/indexing/geoblacklight.json'] |
54 | 55 | ) |
55 | 56 | end |
56 | 57 | end |
|
79 | 80 | expect(harvester.pull_all).to eq(%w[my-institution another-institution]) |
80 | 81 | end |
81 | 82 |
|
82 | | - it 'skips repositories in the denylist' do |
| 83 | + it 'skips repositories with no schema declared' do |
83 | 84 | harvester.pull_all |
84 | | - expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/aardvark.git') |
| 85 | + expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/tool.git') |
85 | 86 | end |
86 | 87 |
|
87 | 88 | it 'skips archived repositories' do |
88 | 89 | harvester.pull_all |
89 | 90 | expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/outdated-institution.git') |
90 | 91 | end |
| 92 | + |
| 93 | + it 'skips repositories with no data' do |
| 94 | + harvester.pull_all |
| 95 | + expect(Git).not_to have_received(:open).with('https://github.com/OpenGeoMetadata/empty.git') |
| 96 | + end |
91 | 97 | end |
92 | 98 |
|
93 | 99 | describe '#clone' do |
|
115 | 121 | expect(Git).to have_received(:clone).exactly(2).times |
116 | 122 | end |
117 | 123 |
|
118 | | - it 'skips repositories in the denylist' do |
| 124 | + it 'skips repositories with no schema declared' do |
| 125 | + harvester.clone_all |
| 126 | + expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/tool.git') |
| 127 | + end |
| 128 | + |
| 129 | + it 'skips archived repositories' do |
| 130 | + harvester.clone_all |
| 131 | + expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/outdated-institution.git') |
| 132 | + end |
| 133 | + |
| 134 | + it 'skips repositories with no data' do |
119 | 135 | harvester.clone_all |
120 | | - expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/aardvark.git') |
| 136 | + expect(Git).not_to have_received(:clone).with('https://github.com/OpenGeoMetadata/empty.git') |
121 | 137 | end |
122 | 138 |
|
123 | 139 | it 'returns the names of repositories cloned' do |
|
0 commit comments