Skip to content

Commit

Permalink
Merge pull request #9318 from joshcooper/noarch_tests
Browse files Browse the repository at this point in the history
Add tests for -noarch
  • Loading branch information
mhashizume authored Apr 11, 2024
2 parents 47f7f3b + dc28505 commit 0fdd52b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/util/rpm_compare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Puppet::Util::RpmCompare
armv5tejl armv6l armv7l m68kmint s390 s390x ia64 x86_64 sh3 sh4
].freeze

ARCH_REGEX = Regexp.new('\.' + ARCH_LIST.join('|\.'))
ARCH_REGEX = Regexp.new(ARCH_LIST.map { |arch| "\\.#{arch}" }.join('|'))

# This is an attempt at implementing RPM's
# lib/rpmvercmp.c rpmvercmp(a, b) in Ruby.
Expand Down
14 changes: 14 additions & 0 deletions spec/shared_examples/rhel_package_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@
allow(arch_provider).to receive(:query).and_return(:ensure => version)
arch_provider.install
end

it "does not move '-noarch' to the end of version" do
version = '1.2.3'
resource = Puppet::Type.type(:package).new(
:name => "#{name}-noarch",
:ensure => version,
:provider =>provider_name
)
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, "#{name}-noarch-#{version}"])
provider = provider_class.new
provider.resource = resource
allow(provider).to receive(:query).and_return(:ensure => version)
provider.install
end
end

describe 'when uninstalling' do
Expand Down
5 changes: 5 additions & 0 deletions spec/unit/util/rpm_compare_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ class RpmTest
expect([version[:epoch], version[:version], version[:release]]).to \
eq([nil, '2.2', 'SNAPSHOT20121119105647'])
end

it 'parses .noarch' do
version = RpmTest.rpm_parse_evr('3.0.12-1.el5.centos.noarch')
expect(version[:arch]).to eq('noarch')
end
end

describe '.compare_values' do
Expand Down

0 comments on commit 0fdd52b

Please sign in to comment.