Skip to content

Commit f860ab4

Browse files
committed
generates checksum files
1 parent 96ac9d9 commit f860ab4

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/stage/generate_checksums.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ def self.write(path)
1313

1414
class GenerateChecksums < Stage
1515
def run(agenda)
16-
# shipment.objid_directories
16+
@bar.steps = shipment.objid_directories.count
17+
shipment.objid_directories.each_with_index do |dir, i|
18+
@bar.step! i, dir
19+
ChecksumFileGenerator.write(dir)
20+
end
1721
end
1822
end

spec/stage/generate_checksums_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,18 @@
1111
end
1212

1313
describe GenerateChecksums do
14+
include_context "uses temp dir"
1415
it "does something" do
15-
shipment = instance_double(Shipment, is_a?: true, objids: [])
16-
described_class.new(shipment)
16+
barcode = "39015002231713"
17+
shipment_path = "#{temp_dir_path}/test_shipment"
18+
item_path = "#{shipment_path}/#{barcode}"
19+
FileUtils.mkdir_p(item_path)
20+
FileUtils.cp("spec/fixtures/10_10_8_400.jp2", item_path)
21+
22+
shipment = Shipment.new(shipment_path)
23+
stage = described_class.new(shipment)
24+
stage.run!
25+
checksum_contents = File.read(File.join(item_path, "checksum.md5"))
26+
expect(checksum_contents).to include(" 10_10_8_400.jp2")
1727
end
1828
end

0 commit comments

Comments
 (0)