Skip to content

Commit 01be2c1

Browse files
committed
Correct gluster::repo::apt spec
This uses an if conditional on the context to avoid an indent level. Also uses compile.and_raise_error to check for compilation failure.
1 parent 3ef81f8 commit 01be2c1

File tree

1 file changed

+70
-79
lines changed

1 file changed

+70
-79
lines changed

spec/classes/repo_apt_spec.rb

Lines changed: 70 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,87 @@
11
require 'spec_helper'
22

33
describe 'gluster::repo::apt', type: :class do
4-
on_supported_os.each do |os, facts|
5-
context "on #{os}" do
6-
let(:facts) do
7-
facts
8-
end
9-
let :pre_condition do
10-
'require ::gluster::params'
11-
end
4+
on_supported_os.each do |os, os_facts|
5+
context "on #{os}", if: os_facts[:osfamily] == 'Debian' do
6+
let(:facts) { os_facts }
7+
let(:pre_condition) { 'require gluster::params' }
128

13-
case facts[:osfamily]
14-
when 'Debian'
15-
context 'with all defaults' do
16-
it { is_expected.to contain_class('gluster::repo::apt') }
17-
it { is_expected.to compile.with_all_deps }
18-
it 'installs' do
19-
is_expected.to contain_apt__source('glusterfs-LATEST').with(
20-
repos: 'main',
21-
release: facts[:lsbdistcodename].to_s,
22-
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/"
23-
)
24-
end
9+
context 'with all defaults' do
10+
it { is_expected.to contain_class('gluster::repo::apt') }
11+
it { is_expected.to compile.with_all_deps }
12+
it 'installs' do
13+
is_expected.to contain_apt__source('glusterfs-LATEST').with(
14+
repos: 'main',
15+
release: facts[:lsbdistcodename].to_s,
16+
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/"
17+
)
18+
end
19+
end
20+
context 'unsupported architecture' do
21+
let :facts do
22+
super().merge(
23+
architecture: 'zLinux'
24+
)
2525
end
26-
context 'unsupported architecture' do
27-
let :facts do
28-
super().merge(
29-
architecture: 'zLinux'
30-
)
31-
end
3226

33-
it 'does not install' do
34-
expect do
35-
is_expected.to create_file('/etc/pki/rpm-gpg/RPM-GPG-KEY-gluster.pub')
36-
end.to raise_error(Puppet::Error, %r{not yet supported})
37-
end
27+
it 'does not install' do
28+
is_expected.to compile.and_raise_error(%r{Architecture zLinux not yet supported})
29+
end
30+
end
31+
context 'latest Gluster with priority' do
32+
let :params do
33+
{
34+
priority: '700'
35+
}
3836
end
39-
context 'latest Gluster with priority' do
40-
let :params do
41-
{
42-
priority: '700'
43-
}
44-
end
4537

46-
it 'installs' do
47-
is_expected.to contain_apt__source('glusterfs-LATEST').with(
48-
repos: 'main',
49-
release: facts[:lsbdistcodename].to_s,
50-
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/",
51-
pin: '700'
52-
)
53-
end
38+
it 'installs' do
39+
is_expected.to contain_apt__source('glusterfs-LATEST').with(
40+
repos: 'main',
41+
release: facts[:lsbdistcodename].to_s,
42+
location: "https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/#{facts[:lsbdistcodename]}/#{facts[:architecture]}/apt/",
43+
pin: '700'
44+
)
5445
end
46+
end
5547

56-
context 'Specific Gluster release 4.1' do
57-
let :params do
58-
{
59-
release: '4.1'
60-
}
61-
end
48+
context 'Specific Gluster release 4.1' do
49+
let :params do
50+
{
51+
release: '4.1'
52+
}
53+
end
6254

63-
it 'installs' do
64-
is_expected.to contain_apt__source('glusterfs-LATEST').with(
65-
repos: 'main',
66-
release: facts[:lsbdistcodename].to_s,
67-
key: {
68-
'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
69-
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub'
70-
},
71-
location: "https://download.gluster.org/pub/gluster/glusterfs/4.1/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
72-
)
73-
end
55+
it 'installs' do
56+
is_expected.to contain_apt__source('glusterfs-LATEST').with(
57+
repos: 'main',
58+
release: facts[:lsbdistcodename].to_s,
59+
key: {
60+
'id' => 'EED3351AFD72E5437C050F0388F6CDEE78FA6D97',
61+
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/4.1/rsa.pub'
62+
},
63+
location: "https://download.gluster.org/pub/gluster/glusterfs/4.1/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
64+
)
7465
end
66+
end
7567

76-
context 'Specific Gluster release 3.12' do
77-
let :params do
78-
{
79-
release: '3.12'
80-
}
81-
end
68+
context 'Specific Gluster release 3.12' do
69+
let :params do
70+
{
71+
release: '3.12'
72+
}
73+
end
8274

83-
it 'installs' do
84-
is_expected.to contain_apt__source('glusterfs-LATEST').with(
85-
repos: 'main',
86-
release: facts[:lsbdistcodename].to_s,
87-
key: {
88-
'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
89-
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub'
90-
},
91-
location: "https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
92-
)
93-
end
75+
it 'installs' do
76+
is_expected.to contain_apt__source('glusterfs-LATEST').with(
77+
repos: 'main',
78+
release: facts[:lsbdistcodename].to_s,
79+
key: {
80+
'id' => '8B7C364430B66F0B084C0B0C55339A4C6A7BD8D4',
81+
'key_source' => 'https://download.gluster.org/pub/gluster/glusterfs/3.12/rsa.pub'
82+
},
83+
location: "https://download.gluster.org/pub/gluster/glusterfs/01.old-releases/3.12/LATEST/Debian/#{facts[:lsbdistcodename]}/amd64/apt/"
84+
)
9485
end
9586
end
9687
end

0 commit comments

Comments
 (0)