Skip to content

Commit ee7d5b5

Browse files
committed
refactor upstream repo detection
1 parent 304d630 commit ee7d5b5

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

spec/acceptance/10_rsyslog_spec.rb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
require 'spec_helper_acceptance'
44

55
def has_upstream_repo
6-
%w[
7-
CentOS
8-
RedHat
9-
OracleLinux
10-
Ubuntu
11-
].include? fact('os.name')
6+
os = fact('os')
7+
case os['family']
8+
when 'RedHat'
9+
return true
10+
else
11+
case os['name']
12+
when 'Ubuntu'
13+
return true
14+
end
15+
end
16+
false
1217
end
1318

1419
describe 'rsyslog' do
@@ -83,14 +88,17 @@ class { 'rsyslog':
8388
# Ensure the rsyslog package was installed from the upstream rsyslog repo
8489
describe 'rsyslog package' do
8590
it 'is installed from upstream repo' do
86-
case os['name']
87-
when 'CentOS', 'RedHat', 'OracleLinux'
91+
case os['family']
92+
when 'RedHat'
8893
expect(command('dnf repoquery --installed --qf "%{from_repo}" rsyslog').stdout.strip).to eq('upstream_rsyslog')
89-
when 'Ubuntu'
90-
# Least ugly way to check where a package was installed from
91-
expect(
92-
command('python3 -c "import apt; print(apt.Cache()[\"rsyslog\"].installed.uri)"').stdout,
93-
).to start_with('https://ppa.launchpadcontent.net/adiscon/v8-stable/ubuntu')
94+
else
95+
case os['name']
96+
when 'Ubuntu'
97+
# Least ugly way to check where a package was installed from
98+
expect(
99+
command('python3 -c "import apt; print(apt.Cache()[\"rsyslog\"].installed.uri)"').stdout,
100+
).to start_with('https://ppa.launchpadcontent.net/adiscon/v8-stable/ubuntu')
101+
end
94102
end
95103
end
96104
end

0 commit comments

Comments
 (0)