Skip to content

Commit

Permalink
Fix duplicate declaration for python-venv package
Browse files Browse the repository at this point in the history
  • Loading branch information
baurmatt committed Nov 26, 2019
1 parent 621548a commit a19bb55
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
12 changes: 5 additions & 7 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
$path = [ '/bin', '/usr/bin', '/usr/sbin', '/usr/local/bin' ],
$environment = [],
) {

include python

if $ensure == 'present' {
$python_version = $version ? {
'system' => $facts['python3_version'],
default => $version,
'system' => $facts['python3_version'],
default => $version,
}

$python_version_parts = split($python_version, '[.]')
Expand All @@ -50,11 +49,10 @@
case $facts['lsbdistcodename'] {
'xenial','bionic','cosmic','disco',
'jessie','stretch','buster': {
ensure_packages ($python3_venv_package, {
before => File[$venv_dir],
})
ensure_packages ($python3_venv_package)
Package[$python3_venv_package] -> File[$venv_dir]
}
default: {}
default: {}
}
}

Expand Down
22 changes: 22 additions & 0 deletions spec/classes/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@
end
end

describe 'with python::python_pyvenvs' do
context 'with two pyenvs' do
let(:params) do
{
python_pyvenvs: {
'/opt/env1' => {
version: '3.8'
},
'/opt/env2' => {
version: '3.8'
}
}
}
end

it { is_expected.to compile }

it { is_expected.to contain_python__pyvenv('/opt/env1').with_ensure('present') }
it { is_expected.to contain_python__pyvenv('/opt/env2').with_ensure('present') }
end
end

describe 'with manage_gunicorn' do
context 'true' do
let(:params) { { manage_gunicorn: true } }
Expand Down
12 changes: 8 additions & 4 deletions spec/defines/pyvenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
'/opt/env'
end

it {
is_expected.to contain_file('/opt/env')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env')
}
context 'with default parameters' do
it { is_expected.to contain_file('/opt/env') }
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env') }

if %w[xenial bionic cosmic disco jessie stretch buster].include?(facts[:lsbdistcodename])
it { is_expected.to contain_package('python3.5-venv').that_comes_before('File[/opt/env]') }
end
end

describe 'when ensure' do
context 'is absent' do
Expand Down

0 comments on commit a19bb55

Please sign in to comment.