Skip to content

Commit 2777d49

Browse files
committed
Add virtualenv unit tests
1 parent 911d406 commit 2777d49

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

spec/defines/virtualenv_spec.rb

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
require 'spec_helper'
2+
3+
describe 'python::virtualenv', type: :define do
4+
on_supported_os.each do |os, facts|
5+
next if os == 'gentoo-3-x86_64'
6+
context "on #{os}" do
7+
let :facts do
8+
facts
9+
end
10+
let :title do
11+
'/opt/env'
12+
end
13+
14+
context 'with default parameters' do
15+
it { is_expected.to compile.with_all_deps }
16+
it { is_expected.to contain_file('/opt/env') }
17+
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') }
18+
end
19+
20+
context 'when virtualenv is defined' do
21+
let(:params) {{ virtualenv: 'virtualenv-3' }}
22+
23+
it { is_expected.to compile.with_all_deps }
24+
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command(%r{virtualenv-3 --no-site-packages -p python .+}) }
25+
end
26+
27+
describe 'when ensure' do
28+
context 'is absent' do
29+
let :params do
30+
{
31+
ensure: 'absent'
32+
}
33+
end
34+
35+
it {
36+
is_expected.to contain_file('/opt/env').with_ensure('absent').with_purge(true)
37+
}
38+
end
39+
end
40+
end # context
41+
end
42+
end

0 commit comments

Comments
 (0)