forked from theforeman/puppet-foreman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforeman_repos_spec.rb
69 lines (61 loc) · 1.59 KB
/
foreman_repos_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
require 'spec_helper'
describe 'foreman::repos' do
let(:title) { 'foreman' }
let(:repo) { '1.18' }
let(:params) { { repo: repo, yum_repo_baseurl: 'http://example.org' } }
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) { facts }
case facts[:osfamily]
when 'RedHat'
yumcode = case os
when /^fedora-/
"f#{facts[:operatingsystemmajrelease]}"
else
"el#{facts[:operatingsystemmajrelease]}"
end
it do
is_expected.to contain_foreman__repos__yum('foreman')
.with_repo(repo)
.with_yumcode(yumcode)
.with_gpgcheck(true)
.with_baseurl('http://example.org')
end
when 'Debian'
it { is_expected.to contain_foreman__repos__apt('foreman').with_repo(repo) }
end
end
end
# TODO: on_supported_os?
context 'on Amazon' do
let :facts do
{
os: {
family: 'Linux',
name: 'Amazon',
},
}
end
it do
is_expected.to contain_foreman__repos__yum('foreman')
.with_repo(repo)
.with_yumcode('el7')
.with_gpgcheck(true)
end
end
context 'on unsupported osfamily' do
let :facts do
{
networking: {
hostname: 'localhost',
},
os: {
family: 'unsupported',
},
}
end
it 'should fail' do
is_expected.to compile.and_raise_error(/#{facts[:hostname]}: This module does not support osfamily #{facts[:osfamily]}/)
end
end
end