Skip to content

Commit

Permalink
Merge pull request #592 from treydock/virtualenv
Browse files Browse the repository at this point in the history
Fix python::virtualenv to allow virtualenv to not require absolute path
  • Loading branch information
bastelfreak authored Dec 13, 2020
2 parents 21abb33 + 2777d49 commit 7941a0c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifests/virtualenv.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Integer $timeout = 1800,
String $pip_args = '',
String $extra_pip_args = '',
Optional[Stdlib::Absolutepath] $virtualenv = undef,
Optional[String[1]] $virtualenv = undef,
) {
include python

Expand Down
42 changes: 42 additions & 0 deletions spec/defines/virtualenv_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'

describe 'python::virtualenv', type: :define do
on_supported_os.each do |os, facts|
next if os == 'gentoo-3-x86_64'
context "on #{os}" do
let :facts do
facts
end
let :title do
'/opt/env'
end

context 'with default parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/opt/env') }
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('virtualenv --no-site-packages -p python /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --proxy= --upgrade pip && /opt/env/bin/pip install --proxy= --upgrade distribute') }
end

context 'when virtualenv is defined' do
let(:params) {{ virtualenv: 'virtualenv-3' }}

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command(%r{virtualenv-3 --no-site-packages -p python .+}) }
end

describe 'when ensure' do
context 'is absent' do
let :params do
{
ensure: 'absent'
}
end

it {
is_expected.to contain_file('/opt/env').with_ensure('absent').with_purge(true)
}
end
end
end # context
end
end

0 comments on commit 7941a0c

Please sign in to comment.