forked from theforeman/puppet-foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeman_repo_spec.rb
94 lines (79 loc) · 2.7 KB
/
foreman_repo_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
require 'spec_helper'
describe 'foreman::repo' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
describe 'with default parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_anchor('foreman::repo') }
it { is_expected.not_to contain_foreman__repos('foreman') }
it do
if facts[:operatingsystem] == 'CentOS' && facts[:operatingsystemmajrelease] == '7'
is_expected.to contain_package('centos-release-scl-rh')
else
is_expected.not_to contain_package('centos-release-scl-rh')
end
end
end
describe 'with minimal parameters' do
let(:params) { {repo: 'nightly'} }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_foreman__repos('foreman')
.with_repo('nightly')
.with_gpgcheck(true)
.with_yum_repo_baseurl('https://yum.theforeman.org')
}
it do
if facts[:operatingsystem] == 'CentOS' && facts[:operatingsystemmajrelease] == '7'
is_expected.to contain_package('centos-release-scl-rh')
else
is_expected.not_to contain_package('centos-release-scl-rh')
end
end
it do
if facts[:operatingsystemmajrelease] == '8'
is_expected.to contain_package('foreman').with_ensure('el8').with_provider('dnfmodule')
else
is_expected.not_to contain_package('ruby')
end
end
end
describe 'with explicit parameters' do
let :params do
{
repo: '1.19',
configure_scl_repo: false,
yum_repo_baseurl: 'https://example.org'
}
end
it { is_expected.to compile.with_all_deps }
it 'should include OS repos' do
is_expected.to contain_foreman__repos('foreman')
.with_repo('1.19')
.with_gpgcheck(true)
.with_yum_repo_baseurl('https://example.org')
end
it { is_expected.not_to contain_package('centos-release-scl-rh') }
it do
is_expected.not_to contain_package('ruby')
end
end
describe 'with repo set to 2.5' do
let :params do
{
repo: '2.5',
configure_scl_repo: false
}
end
it { is_expected.to compile.with_all_deps }
it do
if facts[:operatingsystemmajrelease] == '8'
is_expected.to contain_package('ruby').with_ensure('2.7').with_provider('dnfmodule')
else
is_expected.not_to contain_package('ruby')
end
end
end
end
end
end