Skip to content

Commit de1f7e4

Browse files
authored
Merge pull request #36 from seanmil/fix_tests_rhel_package_provider
Fix unit tests for yum/dnf provider option change
2 parents b189450 + eaa4864 commit de1f7e4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

spec/shared_examples/rhel_package_provider.rb

+13-13
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
it "should call #{provider_name} install for :installed" do
7676
allow(resource).to receive(:should).with(:ensure).and_return(:installed)
77-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, 'mypackage'])
77+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, 'mypackage'])
7878
provider.install
7979
end
8080

@@ -86,7 +86,7 @@
8686

8787
it "should catch #{provider_name} install failures when status code is wrong" do
8888
allow(resource).to receive(:should).with(:ensure).and_return(:installed)
89-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-e', error_level, '-y', :install, name]).and_return(Puppet::Util::Execution::ProcessOutput.new("No package #{name} available.", 0))
89+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, name]).and_return(Puppet::Util::Execution::ProcessOutput.new("No package #{name} available.", 0))
9090
expect {
9191
provider.install
9292
}.to raise_error(Puppet::Error, "Could not find package #{name}")
@@ -102,14 +102,14 @@
102102
it 'should be able to set version' do
103103
version = '1.2'
104104
resource[:ensure] = version
105-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, "#{name}-#{version}"])
105+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, "#{name}-#{version}"])
106106
allow(provider).to receive(:query).and_return(:ensure => version)
107107
provider.install
108108
end
109109
it 'should handle partial versions specified' do
110110
version = '1.3.4'
111111
resource[:ensure] = version
112-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, 'mypackage-1.3.4'])
112+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, 'mypackage-1.3.4'])
113113
allow(provider).to receive(:query).and_return(:ensure => '1.3.4-1.el6')
114114
provider.install
115115
end
@@ -118,7 +118,7 @@
118118
current_version = '1.2'
119119
version = '1.0'
120120
resource[:ensure] = '1.0'
121-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :downgrade, "#{name}-#{version}"])
121+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :downgrade, "#{name}-#{version}"])
122122
allow(provider).to receive(:query).and_return({:ensure => current_version}, {:ensure => version})
123123
provider.install
124124
end
@@ -127,7 +127,7 @@
127127
current_version = '1.0'
128128
version = '1.2'
129129
resource[:ensure] = '1.2'
130-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', upgrade_command, "#{name}-#{version}"])
130+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', upgrade_command, "#{name}-#{version}"])
131131
allow(provider).to receive(:query).and_return({:ensure => current_version}, {:ensure => version})
132132
provider.install
133133
end
@@ -136,7 +136,7 @@
136136
current_version = ''
137137
version = '1.2'
138138
resource[:ensure] = :latest
139-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, name])
139+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, name])
140140
allow(provider).to receive(:query).and_return({:ensure => current_version}, {:ensure => version})
141141
provider.install
142142
end
@@ -145,30 +145,30 @@
145145
current_version = '1.0'
146146
version = '1.2'
147147
resource[:ensure] = :latest
148-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', upgrade_command, name])
148+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', upgrade_command, name])
149149
allow(provider).to receive(:query).and_return({:ensure => current_version}, {:ensure => version})
150150
provider.install
151151
end
152152

153153
it 'should accept install options' do
154154
resource[:ensure] = :installed
155155
resource[:install_options] = ['-t', {'-x' => 'expackage'}]
156-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', ['-t', '-x=expackage'], :install, name])
156+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', ['-t', '-x=expackage'], :install, name])
157157
provider.install
158158
end
159159

160160
it 'allow virtual packages' do
161161
resource[:ensure] = :installed
162162
resource[:allow_virtual] = true
163-
expect(Puppet::Util::Execution).not_to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :list, name])
164-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, name])
163+
expect(Puppet::Util::Execution).not_to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :list, name])
164+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, name])
165165
provider.install
166166
end
167167

168168
it 'moves architecture to end of version' do
169169
version = '1.2.3'
170170
arch_resource[:ensure] = version
171-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, "#{name}-#{version}.#{arch}"])
171+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, "#{name}-#{version}.#{arch}"])
172172
allow(arch_provider).to receive(:query).and_return(:ensure => version)
173173
arch_provider.install
174174
end
@@ -180,7 +180,7 @@
180180
:ensure => version,
181181
:provider =>provider_name
182182
)
183-
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-d', '0', '-e', error_level, '-y', :install, "#{name}-noarch-#{version}"])
183+
expect(Puppet::Util::Execution).to receive(:execute).with(["/usr/bin/#{provider_name}", '-y', :install, "#{name}-noarch-#{version}"])
184184
provider = provider_class.new
185185
provider.resource = resource
186186
allow(provider).to receive(:query).and_return(:ensure => version)

spec/unit/provider/package/dnfmodule_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@
241241
it "does not try to disable if package is already disabled" do
242242
allow(described_class).to receive(:command).with(:dnf).and_return(dnf_path)
243243
allow(Puppet::Util::Execution).to receive(:execute)
244-
.with("/usr/bin/dnf module list -y -d 0 -e 1")
244+
.with("/usr/bin/dnf module list -y")
245245
.and_return("baz 1.2 [d][x] common [d], complete Package Description")
246246
resource[:ensure] = :disabled
247247
expect(provider).to be_insync(:disabled)
@@ -254,7 +254,7 @@
254254

255255
it "returns an array of enabled modules" do
256256
allow(Puppet::Util::Execution).to receive(:execute)
257-
.with("/usr/bin/dnf module list -y -d 0 -e 1")
257+
.with("/usr/bin/dnf module list -y")
258258
.and_return(packages)
259259

260260
enabled_packages = described_class.instances.map { |package| package.properties }

0 commit comments

Comments
 (0)