Merge pull request #6747 from betagouv/US/fix-flacky-spec

wip - works from time to time (rspec ./spec/services/procedure_archive_service_spec.rb:181)
This commit is contained in:
LeSim 2021-12-14 14:29:11 +01:00 committed by GitHub
commit 4f80ab6374
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,7 +182,7 @@ describe ProcedureArchiveService do
service.collect_files_archive(archive, instructeur) service.collect_files_archive(archive, instructeur)
archive.file.open do |f| archive.file.open do |f|
files = ZipTricks::FileReader.read_zip_structure(io: f) zip_entries = ZipTricks::FileReader.read_zip_structure(io: f)
structure = [ structure = [
"procedure-#{procedure.id}/", "procedure-#{procedure.id}/",
"procedure-#{procedure.id}/dossier-#{dossier.id}/", "procedure-#{procedure.id}/dossier-#{dossier.id}/",
@ -191,8 +191,14 @@ describe ProcedureArchiveService do
"procedure-#{procedure.id}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf", "procedure-#{procedure.id}/dossier-#{dossier.id}/export-#{dossier.id}-05-03-2021-00-00-#{dossier.id}.pdf",
"procedure-#{procedure.id}/LISEZMOI.txt" "procedure-#{procedure.id}/LISEZMOI.txt"
] ]
expect(files.map(&:filename)).to match_array(structure) expect(zip_entries.map(&:filename)).to match_array(structure)
expect(extract(f, files.last)).to match(/Impossible de .* .*cni.*png/) zip_entries.map do |entry|
next unless entry.filename == "procedure-#{procedure.id}/LISEZMOI.txt"
extracted_content = ""
extractor = entry.extractor_from(f)
extracted_content << extractor.extract(1024 * 1024) until extractor.eof?
expect(extracted_content).to match(/Impossible de .* .*cni.*png/)
end
end end
end end
end end