-
-
Notifications
You must be signed in to change notification settings - Fork 374
/
Copy pathpyvenv_spec.rb
99 lines (85 loc) · 3 KB
/
pyvenv_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# frozen_string_literal: true
require 'spec_helper'
describe 'python::pyvenv', type: :define do
on_supported_os.each do |os, facts|
next if os == 'gentoo-3-x86_64'
context "on #{os}" do
let :facts do
# python3 is required to use pyvenv
facts.merge(
python3_version: '3.5.1'
)
end
let :title do
'/opt/env'
end
context 'with default parameters' do
it { is_expected.to contain_file('/opt/env').that_requires('Class[python::install]') }
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools') }
end
describe 'when ensure' do
context 'is absent' do
let :params do
{
ensure: 'absent'
}
end
it {
expect(subject).to contain_file('/opt/env').with_ensure('absent').with_purge(true)
}
end
end
context 'custom index is provided' do
let :params do
{
index: 'https://site.tld',
}
end
it { is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install -i https://site.tld --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install -i https://site.tld --upgrade setuptools') }
end
end
context "prompt on #{os} with python 3.6" do
let :facts do
# python 3.6 is required for venv and prompt
facts.merge(
python3_version: '3.6.1'
)
end
let :title do
'/opt/env'
end
context 'with prompt' do
let :params do
{
prompt: 'custom prompt',
}
end
it {
is_expected.to contain_file('/opt/env').that_requires('Class[python::install]')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('python3.6 -m venv --clear --prompt custom\\ prompt /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools')
}
end
end
context "prompt on #{os} with python 3.5" do
let :facts do
facts.merge(
python3_version: '3.5.1'
)
end
let :title do
'/opt/env'
end
context 'with prompt' do
let :params do
{
prompt: 'custom prompt',
}
end
it {
is_expected.to contain_file('/opt/env').that_requires('Class[python::install]')
is_expected.to contain_exec('python_virtualenv_/opt/env').with_command('pyvenv-3.5 --clear /opt/env && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade pip && /opt/env/bin/pip --log /opt/env/pip.log install --upgrade setuptools')
}
end
end
end
end