Skip to content

Commit

Permalink
Add method to loop through all the storage roots when seeding.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommy Ingulfsen committed Nov 1, 2017
1 parent 8564409 commit 88d7e21
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/audit/moab_to_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ def self.seed_catalog(storage_dir)
end
results
end

# Shameless green. In order to run several seed "jobs" in parallel, we would have to refactor.
def seed_from_disk
results = []
Settings.moab.storage_roots.each do |storage_root|
results << self.class.seed_catalog("#{storage_root[1]}/#{Settings.moab.storage_trunk}")
end
results.flatten
end
end
22 changes: 22 additions & 0 deletions spec/lib/audit/moab_to_catalog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
PreservationPolicy.seed_from_config
end

describe "#seed_from_disk" do
let(:m2c) { described_class.new }

it 'calls seed_catalog once per storage root' do
expect(described_class).to receive(:seed_catalog).exactly(Settings.moab.storage_roots.count).times
m2c.seed_from_disk
end

it 'calls seed_catalog with the right arguments' do
Settings.moab.storage_roots.each do |storage_root|
expect(described_class).to receive(:seed_catalog).with("#{storage_root[1]}/#{Settings.moab.storage_trunk}")
end
m2c.seed_from_disk
end

it 'returns the right type and number of results' do
seed_results = m2c.seed_from_disk
expect(seed_results).to be_an_instance_of Array
expect(seed_results.size).to eq(5)
end
end

describe ".check_existence" do
let(:subject) { described_class.check_existence(storage_dir, true) }

Expand Down

0 comments on commit 88d7e21

Please sign in to comment.