Skip to content

Commit 5ab8d48

Browse files
authored
Merge pull request #9138 from evgeni/enable-right-stream
(PUP-11985) correctly enable module:stream without default profile with dnfmodule
2 parents f739469 + 9fe028d commit 5ab8d48

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/puppet/provider/package/dnfmodule.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def install
9393
# module has no default profile and no profile was requested, so just enable the stream
9494
# DNF versions prior to 4.2.8 do not need this workaround
9595
# see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
96-
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
96+
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(args)}$/
9797
enable(args)
9898
else
9999
raise

spec/unit/provider/package/dnfmodule_spec.rb

+22-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
provider.install
124124
end
125125

126-
it "should just enable the module if it has no default profile(missing groups or modules)" do
126+
it "should just enable the module if it has no default profile (missing groups or modules)" do
127127
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
128128
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
129129
resource[:ensure] = :present
@@ -132,7 +132,17 @@
132132
provider.install
133133
end
134134

135-
it "should just enable the module if it has no default profile(broken groups or modules)" do
135+
it "should just enable the module with the right stream if it has no default profile (missing groups or modules)" do
136+
stream = '12.3'
137+
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}:#{stream}")
138+
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
139+
resource[:ensure] = stream
140+
expect(provider).to receive(:execute).with(array_including('install')).ordered
141+
expect(provider).to receive(:execute).with(array_including('enable')).ordered
142+
provider.install
143+
end
144+
145+
it "should just enable the module if it has no default profile (broken groups or modules)" do
136146
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}")
137147
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
138148
resource[:ensure] = :present
@@ -141,6 +151,16 @@
141151
provider.install
142152
end
143153

154+
it "should just enable the module with the right stream if it has no default profile (broken groups or modules)" do
155+
stream = '12.3'
156+
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}:#{stream}")
157+
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
158+
resource[:ensure] = stream
159+
expect(provider).to receive(:execute).with(array_including('install')).ordered
160+
expect(provider).to receive(:execute).with(array_including('enable')).ordered
161+
provider.install
162+
end
163+
144164
it "should just enable the module if enable_only = true" do
145165
resource[:ensure] = :present
146166
resource[:enable_only] = true

0 commit comments

Comments
 (0)