Skip to content

Commit

Permalink
Switch to repomd_parser 1.1.0 interface
Browse files Browse the repository at this point in the history
With the update to 1.1.0 the library interface changed and this needed
to be updated.
  • Loading branch information
felixsch committed Apr 10, 2024
1 parent 88a8817 commit e326e83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/rmt/mirror/repomd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def mirror_metadata
key_file = file_reference('repodata/repomd.xml.key', to: temp(:metadata))
check_signature(key_file: key_file, signature_file: signature_file, metadata_file: repomd_xml)

metadata_files = RepomdParser::RepomdXmlParser.new(repomd_xml.local_path).parse
metadata_files = RepomdParser::RepomdXmlParser.new.parse_file(repomd_xml.local_path)
.map do |reference|
ref = RMT::Mirror::FileReference.build_from_metadata(reference, base_dir: temp(:metadata), base_url: repomd_xml.base_url)
enqueue ref
Expand Down Expand Up @@ -66,8 +66,10 @@ def parse_packages_metadata(metadata_references)
xml_parsers = { deltainfo: RepomdParser::DeltainfoXmlParser,
primary: RepomdParser::PrimaryXmlParser }

metadata_references
.map { |file| xml_parsers[file.type]&.new(file.local_path) }.compact
.map(&:parse).flatten
metadata_references.map do |file|
next unless xml_parsers.key? file.type

xml_parsers[file.type].new.parse_file(file.local_path)
end.flatten.compact
end
end
6 changes: 2 additions & 4 deletions spec/lib/rmt/mirror/repomd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
end
let(:signature_file) { RMT::Mirror::FileReference.new(relative_path: 'repodata/repomd.xml.asc', **ref_configuration) }
let(:key_file) { RMT::Mirror::FileReference.new(relative_path: 'repodata/repomd.xml.key', **ref_configuration) }
let(:repomd_parser) { RepomdParser::RepomdXmlParser.new(repomd_ref.local_path) }
let(:parsed_repomd) { RepomdParser::RepomdXmlParser.new.parse_file(repomd_ref.local_path) }

before do
allow(repomd).to receive(:temp).with(:metadata).and_return('a')
Expand All @@ -104,9 +104,7 @@
allow(repomd).to receive(:download_cached!).and_return(repomd_ref)
allow(repomd).to receive(:check_signature)
allow(repomd).to receive(:download_enqueued)
allow(RepomdParser::RepomdXmlParser).to receive(:new).with(repomd_ref.local_path).and_return(repomd_parser)

expect(repomd_parser).to receive(:parse).and_call_original
allow_any_instance_of(RepomdParser::RepomdXmlParser).to receive(:parse_file).with(repomd_ref.local_path).and_return(parsed_repomd)
expect(repomd).to receive(:enqueue).with(duck_type(:local_path)).exactly(4).times

metadatas = repomd.mirror_metadata
Expand Down

0 comments on commit e326e83

Please sign in to comment.