Skip to content

Commit

Permalink
python version is needed for spec test
Browse files Browse the repository at this point in the history
  • Loading branch information
jradmacher committed Dec 6, 2018
1 parent b159288 commit a433a6c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions manifests/pyvenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

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

Expand All @@ -56,7 +56,7 @@
}

# pyvenv is deprecated since 3.6 and will be removed in 3.8
if (versioncmp($::python3_version, '3.6') >=0) {
if (versioncmp($facts['python3_version'], '3.6') >=0) {
$virtualenv_cmd = "${python::exec_prefix}python${python_version} -m venv"
} else {
$virtualenv_cmd = "${python::exec_prefix}pyvenv-${python_version}"
Expand Down
3 changes: 3 additions & 0 deletions spec/default_module_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
python_version: "2.7"
python3_version: ~
9 changes: 6 additions & 3 deletions spec/defines/pyvenv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
on_supported_os.each do |os, facts|
context("on #{os} ") do
let :facts do
facts
# python3 is required to use pyvenv
facts.merge({
:python3_version => '3.4',
})
end
let :title do
'/opt/env'
end

it {
is_expected.to contain_file('/opt/env')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv --clear /opt/env')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.4 --clear /opt/env')
}

describe 'when ensure' do
Expand All @@ -28,6 +31,6 @@
}
end
end
end
end #context
end
end

0 comments on commit a433a6c

Please sign in to comment.