Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $real_pkgname for pip uninstall command #607

Merged
merged 7 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifests/pip.pp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@

default: {
# Anti-action, uninstall.
$command = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${name}"
$command = "echo y | ${pip_env} uninstall ${uninstall_args} ${proxy_flag} ${real_pkgname}"
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved
$unless_command = "! ${pip_env} list | grep -i -e '${grep_regex}'"
}
}
Expand Down
57 changes: 57 additions & 0 deletions spec/acceptance/pip_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
require 'spec_helper_acceptance'

describe 'python::pip defined resource' do
context 'install package with custom name' do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
version => '3',
dev => 'present',
}

python::pip { 'agent package':
pkgname => 'agent',
ensure => '0.1.2',
}
PUPPET

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
bastelfreak marked this conversation as resolved.
Show resolved Hide resolved

describe command('/usr/bin/pip list') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{agent.* 0\.1\.2} }
end

context 'uninstall package with custom name' do
it 'works with no errors' do
pp = <<-PUPPET
class { 'python':
version => '3',
dev => 'present',
}

python::pip { 'agent package install':
pkgname => 'agent',
ensure => '0.1.2',
}

python::pip { 'agent package uninstall':
pkgname => 'agent',
ensure => 'absent',
require => Python::Pip['agent package install'],
}

PUPPET

apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe command('/usr/bin/pip list') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.not_to match %r{agent.* 0\.1\.2} }
end
end

8 changes: 8 additions & 0 deletions spec/defines/pip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@

it { is_expected.to contain_exec('pip_uninstall_rpyc').with_command(%r{uninstall.*rpyc$}) }
end

context 'passes correct package name' do
let(:params) { { ensure: 'absent', 'pkgname': 'r-pyc' } }

it { is_expected.not_to contain_exec('pip_install_rpyc') }

it { is_expected.to contain_exec('pip_uninstall_rpyc').with_command(%r{uninstall.*r-pyc$}) }
end
end
end
end
Expand Down