spec: Fix some rubocop offences
MODIFY
spec/classes/database_postgresql_spec.rb
spec/classes/database_postgresql_spec.rb
@@ -19,21 +19,20 @@ describe 'zabbix::database::postgresql' do
case facts[:os]['name']
when 'CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux'
# Path for version 2.4 on RedHat
- path_for2 = "/usr/share/doc/zabbix-*-pgsql-2.4*/create"
+ path_for2 = '/usr/share/doc/zabbix-*-pgsql-2.4*/create'
else
# Path for version 2.4 on Debian
- path_for2 = "/usr/share/zabbix-*-pgsql"
+ path_for2 = '/usr/share/zabbix-*-pgsql'
end
%w[2.4 3.2 3.4 4.0 4.2 4.4 5.0 5.2].each do |zabbix_version|
-
case facts[:os]['name']
when 'CentOS', 'RedHat', 'OracleLinux', 'VirtuozzoLinux'
# Path for versions >= 3.x on RedHat
path_for3_and_up = "/usr/share/doc/zabbix-*-pgsql-#{zabbix_version}*/"
else
# Path for versions >= 3.x on Debian
- path_for3_and_up = "/usr/share/doc/zabbix-*-pgsql"
+ path_for3_and_up = '/usr/share/doc/zabbix-*-pgsql'
end
describe "when zabbix_type is server and version is #{zabbix_version}" do
@@ -52,8 +51,8 @@ describe 'zabbix::database::postgresql' do
it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') }
if zabbix_version != '2.4'
it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path_for3_and_up} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f create.sql && touch /etc/zabbix/.schema.done") }
- it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("touch /etc/zabbix/.images.done") }
- it { is_expected.to contain_exec('zabbix_server_data.sql').with_command("touch /etc/zabbix/.data.done") }
+ it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') }
+ it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') }
else
it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path_for2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f schema.sql && touch /etc/zabbix/.schema.done") }
it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("cd #{path_for2} && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f images.sql && touch /etc/zabbix/.images.done") }

MODIFY
spec/classes/web_spec.rb
spec/classes/web_spec.rb
@@ -79,16 +79,16 @@ describe 'zabbix::web' do
'php5-pgsql'
end
- if facts[:osfamily] == 'RedHat'
- if facts[:operatingsystemmajrelease].to_i == 7 and
- !['VirtuozzoLinux', 'OracleLinux', 'Scientific'].include?(facts[:os]['name']) and
+ packages = if facts[:osfamily] == 'RedHat'
+ if facts[:operatingsystemmajrelease].to_i == 7 &&
+ !%w[VirtuozzoLinux OracleLinux Scientific].include?(facts[:os]['name']) &&
zabbix_version == '5.0'
- packages = ['zabbix-web-pgsql-scl', 'zabbix-web']
+ ['zabbix-web-pgsql-scl', 'zabbix-web']
else
- packages = ['zabbix-web-pgsql', 'zabbix-web']
+ ['zabbix-web-pgsql', 'zabbix-web']
end
else
- packages = ['zabbix-frontend-php', pgsqlpackage]
+ ['zabbix-frontend-php', pgsqlpackage]
end
packages.each do |package|
@@ -98,7 +98,6 @@ describe 'zabbix::web' do
end
end
- %w[4.4 5.0].each do |zabbix_version|
describe 'with database_type as mysql' do
let :params do
super().merge(database_type: 'mysql')
@@ -127,7 +126,6 @@ describe 'zabbix::web' do
end
it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'MYSQL'}) }
end
- end
it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php') }

spec: Fix some rubocop offences

Signed-off-by: Christos Papageorgiou <root.expert.xda@gmail.com>