Skip to content

Commit 432708e

Browse files
authored
Merge pull request voxpupuli#497 from syseleven/fix_reassigned_variable
Fix a reassigned variable
2 parents 734acec + 94d6218 commit 432708e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

manifests/pip.pp

+6-4
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@
174174
$pip_install = "${pip_env} --log ${log}/pip.log install"
175175
$pip_common_args = "${pypi_index} ${proxy_flag} ${install_args} ${install_editable} ${source}"
176176

177-
$pip_exec_name = "pip_install_${name}"
178-
179177
# Explicit version out of VCS when PIP supported URL is provided
180178
if $source =~ /^'(git\+|hg\+|bzr\+|svn\+)(http|https|ssh|svn|sftp|ftp|lp|git)(:\/\/).+'$/ {
181179
if $_ensure != present and $_ensure != latest {
@@ -221,14 +219,18 @@
221219

222220
default: {
223221
# Anti-action, uninstall.
224-
$pip_exec_name = "pip_uninstall_${name}"
225222
$command = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}"
226223
$unless_command = "! ${pip_env} list | grep -i -e '${grep_regex}'"
227224
}
228225
}
229226
}
230227

231-
exec { $pip_exec_name:
228+
$pip_installer = ($ensure == 'absent') ? {
229+
true => "pip_uninstall_${name}",
230+
false => "pip_install_${name}",
231+
}
232+
233+
exec { $pip_installer:
232234
command => $command,
233235
unless => $unless_command,
234236
user => $owner,

spec/defines/pip_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@
106106
it { is_expected.to contain_exec('pip_install_rpyc').with_unless(%r{wordpress-json}) }
107107
end
108108
end
109+
110+
describe 'uninstall' do
111+
context 'adds correct title' do
112+
let(:params) { { ensure: 'absent' } }
113+
114+
it { is_expected.not_to contain_exec('pip_install_rpyc') }
115+
116+
it { is_expected.to contain_exec('pip_uninstall_rpyc').with_command(%r{uninstall.*rpyc$}) }
117+
end
118+
end
109119
end
110120
end
111121

0 commit comments

Comments
 (0)