Skip to content

Commit

Permalink
python::requirements: make cwd optional (again)
Browse files Browse the repository at this point in the history
This was optional before
#580 was merged.
  • Loading branch information
bastelfreak committed Dec 3, 2020
1 parent 0ca4bd8 commit 29fb6d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions manifests/requirements.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# @param src Pip --src parameter to; if the requirements file contains --editable resources, this parameter specifies where they will be installed. See the pip documentation for more.
# @param environment Additional environment variables required to install the packages.
# @param forceupdate Run a pip install requirements even if we don't receive an event from the requirements file - Useful for when the requirements file is written as part of a resource other than file (E.g vcsrepo)
# @param cwd The directory from which to run the "pip install" command.
# @param cwd The directory from which to run the "pip install" command.
# @param extra_pip_args Extra arguments to pass to pip after the requirements file
# @param manage_requirements Create the requirements file if it doesn't exist.
# @param fix_requirements_owner Change owner and group of requirements file.
Expand All @@ -35,7 +35,7 @@
Any $src = false,
Array $environment = [],
Boolean $forceupdate = false,
Stdlib::Absolutepath $cwd = undef,
Optional[Stdlib::Absolutepath] $cwd = undef,
String $extra_pip_args = '',
Boolean $manage_requirements = true,
Boolean $fix_requirements_owner = true,
Expand Down
32 changes: 18 additions & 14 deletions spec/defines/requirements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

describe 'python::requirements', 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
Expand All @@ -15,8 +14,7 @@
context 'with /requirements.txt' do
let :params do
{
requirements: '/requirements.txt',
cwd: '/foo'
requirements: '/requirements.txt'
}
end

Expand All @@ -35,26 +33,32 @@
let :params do
{
owner: 'bob',
group: 'bob',
cwd: '/foo'
group: 'bob'
}
end

it { is_expected.to compile.and_raise_error(%r{root user must be used when virtualenv is system}) }
end
end

context 'default' do
let :params do
{
'cwd': '/foo'
}
end
context 'without parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('python::config') }
it { is_expected.to contain_class('python::install') }
it { is_expected.to contain_class('python::params') }
it { is_expected.to contain_class('python') }
it { is_expected.to contain_exec('python_requirements/requirements.txt') }
it { is_expected.to contain_package('pip') }
it { is_expected.to contain_package('python') }
it { is_expected.to contain_package('virtualenv') }
it { is_expected.to contain_package('gunicorn') }
it { is_expected.to contain_file('/requirements.txt').with_owner('root').with_group('root') }
end

describe 'without cwd' do
it { is_expected.to compile.and_raise_error(%r{parameter 'cwd' expects a Stdlib::Absolutepath}) }
if facts[:os]['name'] == 'Gentoo'
it { is_expected.not_to contain_package('python-dev') }
else
it { is_expected.to contain_package('python-dev') }
end
end
end
end
Expand Down

0 comments on commit 29fb6d5

Please sign in to comment.