File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,15 @@ def run(agenda)
1616 @bar . steps = shipment . objid_directories . count
1717 shipment . objid_directories . each_with_index do |dir , i |
1818 @bar . step! i , dir
19+ remove_existing_checksum_file ( dir )
1920 ChecksumFileGenerator . write ( dir )
2021 end
2122 end
23+
24+ private
25+
26+ def remove_existing_checksum_file ( dir )
27+ checksum_file_path = File . join ( dir , "checksum.md5" )
28+ FileUtils . rm_f ( checksum_file_path ) if File . exist? ( checksum_file_path )
29+ end
2230end
Original file line number Diff line number Diff line change 1212
1313describe GenerateChecksums do
1414 include_context "uses temp dir"
15- it "does something" do
16- barcode = "39015002231713"
17- shipment_path = "#{ temp_dir_path } /test_shipment"
18- item_path = "#{ shipment_path } /#{ barcode } "
15+ let ( :barcode ) { "39015002231713" }
16+ let ( :shipment_path ) { "#{ temp_dir_path } /test_shipment" }
17+ let ( :item_path ) { "#{ shipment_path } /#{ barcode } " }
18+ let ( :shipment ) { Shipment . new ( shipment_path ) }
19+ subject do
20+ described_class . new ( shipment , config : Config . new ( { no_progress : true } ) )
21+ end
22+
23+ def set_up_shipment
1924 FileUtils . mkdir_p ( item_path )
2025 FileUtils . cp ( "spec/fixtures/10_10_8_400.jp2" , item_path )
26+ end
27+
28+ it "creates a checksum file" do
29+ set_up_shipment
30+
31+ subject . run!
32+ checksum_contents = File . read ( File . join ( item_path , "checksum.md5" ) )
33+ expect ( checksum_contents ) . to include ( " 10_10_8_400.jp2" )
34+ end
2135
22- shipment = Shipment . new ( shipment_path )
23- stage = described_class . new ( shipment )
24- stage . run!
36+ it "original checksum file is removed before calculating checksum" do
37+ set_up_shipment
38+ FileUtils . touch ( "#{ item_path } /checksum.md5" )
39+ subject . run!
2540 checksum_contents = File . read ( File . join ( item_path , "checksum.md5" ) )
2641 expect ( checksum_contents ) . to include ( " 10_10_8_400.jp2" )
42+ expect ( checksum_contents ) . not_to include ( " checksum.md5" )
2743 end
2844end
You can’t perform that action at this time.
0 commit comments