forked from theforeman/puppet-puppet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuppet_agent_install_spec.rb
116 lines (99 loc) · 3.32 KB
/
puppet_agent_install_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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
require 'spec_helper'
describe 'puppet::agent::install' do
on_os_under_test.each do |os, facts|
context "on #{os}" do
if Puppet.version < '4.0'
if facts[:osfamily] == 'FreeBSD'
client_package = 'puppet38'
else
client_package = 'puppet'
end
additional_facts = {}
else
if facts[:osfamily] == 'FreeBSD'
if Puppet.version < '5.0'
client_package = 'puppet4'
else
client_package = 'puppet5'
end
additional_facts = {}
else
client_package = 'puppet-agent'
if facts[:osfamily] == 'windows'
additional_facts = {}
else
additional_facts = {:rubysitedir => '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0'}
end
end
end
let (:facts) do
facts.merge(additional_facts)
end
describe 'with default parameters' do
let :pre_condition do
'include ::puppet'
end
if facts[:osfamily] == 'windows'
it 'should define provider as chocolatey on Windows' do
should contain_package(client_package).with_provider('chocolatey')
end
else
it 'should not define provider on non-Windows' do
should contain_package(client_package).without_provider(nil)
end
end
end
describe "when manage_packages => false" do
let :pre_condition do
"class { 'puppet': manage_packages => false }"
end
it 'should not contain Package[puppet]' do
should_not contain_package('puppet')
end
it 'should not contain Package[puppet-agent]' do
should_not contain_package('puppet-agent')
end
end
describe "when manage_packages => 'agent'" do
let :pre_condition do
"class { 'puppet': manage_packages => 'agent' }"
end
it 'should contain Package[puppet]' do
should contain_package(client_package)
end
end
describe "when manage_packages => 'server'" do
let :pre_condition do
"class { 'puppet': manage_packages => 'server' }"
end
it 'should not contain Package[puppet]' do
should_not contain_package('puppet')
end
it 'should not contain Package[puppet-agent]' do
should_not contain_package('puppet-agent')
end
end
if facts[:osfamily] == 'windows'
describe "when package_provider => 'msi'" do
let :pre_condition do
"class { 'puppet': package_provider => 'msi', }"
end
it 'should define provider as msi' do
should contain_package(client_package).with_provider('msi')
end
end
describe "when package_provider => 'windows' and source is defined" do
let :pre_condition do
"class { 'puppet': package_provider => 'windows', package_source => 'C:\\Temp\\puppet.exe' }"
end
it 'should define provider as windows' do
should contain_package(client_package).with_provider('windows')
end
it 'should define source as C:\Temp\puppet.exe' do
should contain_package(client_package).with_source('C:\Temp\puppet.exe')
end
end
end
end
end
end