Skip to content

Commit 50886bf

Browse files
authored
Merge pull request voxpupuli#607 from brabiega/patch-1
Use $real_pkgname for pip uninstall command
2 parents 7dd4543 + f36ea4a commit 50886bf

3 files changed

Lines changed: 84 additions & 1 deletion

File tree

manifests/pip.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220

221221
default: {
222222
# Anti-action, uninstall.
223-
$command = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}"
223+
$command = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${real_pkgname}"
224224
$unless_command = "! ${pip_env} list | grep -i -e '${grep_regex}'"
225225
}
226226
}

spec/acceptance/pip_spec.rb

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'python::pip defined resource' do
4+
context 'install package with custom name' do
5+
it 'works with no errors' do
6+
pp = <<-PUPPET
7+
class { 'python':
8+
version => '3',
9+
dev => 'present',
10+
}
11+
12+
python::pyvenv { '/opt/test-venv':
13+
ensure => 'present',
14+
systempkgs => false,
15+
mode => '0755',
16+
pip_version => '<= 20.3.4',
17+
}
18+
19+
python::pip { 'agent package':
20+
virtualenv => '/opt/test-venv',
21+
pkgname => 'agent',
22+
ensure => '0.1.2',
23+
}
24+
PUPPET
25+
26+
apply_manifest(pp, catch_failures: true)
27+
apply_manifest(pp, catch_changes: true)
28+
end
29+
end
30+
31+
describe command('/opt/test-venv/bin/pip list') do
32+
its(:exit_status) { is_expected.to eq 0 }
33+
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
34+
end
35+
36+
context 'uninstall package with custom name' do
37+
it 'works with no errors' do
38+
pp = <<-PUPPET
39+
class { 'python':
40+
version => '3',
41+
dev => 'present',
42+
}
43+
44+
python::pyvenv { '/opt/test-venv':
45+
ensure => 'present',
46+
systempkgs => false,
47+
mode => '0755',
48+
pip_version => '<= 20.3.4',
49+
}
50+
51+
python::pip { 'agent package install':
52+
ensure => '0.1.2',
53+
pkgname => 'agent',
54+
virtualenv => '/opt/test-venv',
55+
}
56+
57+
python::pip { 'agent package uninstall custom pkgname':
58+
ensure => 'absent',
59+
pkgname => 'agent',
60+
virtualenv => '/opt/test-venv',
61+
require => Python::Pip['agent package install'],
62+
}
63+
64+
PUPPET
65+
66+
apply_manifest(pp, catch_failures: true)
67+
end
68+
end
69+
70+
describe command('/opt/test-venv/bin/pip list') do
71+
its(:exit_status) { is_expected.to eq 0 }
72+
its(:stdout) { is_expected.not_to match %r{agent.* 0\.1\.2} }
73+
end
74+
end
75+

spec/defines/pip_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@
116116

117117
it { is_expected.to contain_exec('pip_uninstall_rpyc').with_command(%r{uninstall.*rpyc$}) }
118118
end
119+
120+
context 'passes correct package name' do
121+
let(:params) { { ensure: 'absent', 'pkgname': 'r-pyc' } }
122+
123+
it { is_expected.not_to contain_exec('pip_install_rpyc') }
124+
125+
it { is_expected.to contain_exec('pip_uninstall_rpyc').with_command(%r{uninstall.*r-pyc$}) }
126+
end
119127
end
120128
end
121129
end

0 commit comments

Comments
 (0)