Skip to content

Commit

Permalink
Merge pull request #387 from bastelfreak/userparameters
Browse files Browse the repository at this point in the history
migrate userparameters tests to rspec-puppet-facts
  • Loading branch information
bastelfreak authored May 23, 2017
2 parents 0786f2f + a01c45e commit f0eefee
Showing 1 changed file with 28 additions and 37 deletions.
65 changes: 28 additions & 37 deletions spec/defines/userparameters_spec.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
require 'spec_helper'

describe 'zabbix::userparameters', type: :define do
let :facts do
{
osfamily: 'RedHat',
operatingsystem: 'RedHat',
operatingsystemrelease: '6.5',
operatingsystemmajrelease: '6',
architecture: 'x86_64',
lsbdistid: 'RedHat',
concat_basedir: '/tmp',
is_pe: false,
puppetversion: Puppet.version,
facterversion: Facter.version,
ipaddress: '192.168.1.10',
lsbdistcodename: '',
id: 'root',
kernel: 'Linux',
path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin',
systemd: false
}
end
let(:title) { 'mysqld' }
let(:pre_condition) { 'class { "zabbix::agent": include_dir => "/etc/zabbix/zabbix_agentd.d" }' }
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
systemd_fact = case facts[:os]['family']
when 'Archlinux', 'Fedora'
{ systemd: true }
else
{ systemd: false }
end
facts.merge(systemd_fact)
end
let(:title) { 'mysqld' }
let(:pre_condition) { 'class { "zabbix::agent": include_dir => "/etc/zabbix/zabbix_agentd.d" }' }

context 'with an content' do
let(:params) { { content: 'UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive' } }
context 'with an content' do
let(:params) { { content: 'UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive' } }

it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_ensure('present') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_content %r{^UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive$} }
it { is_expected.to contain_class('zabbix::params') }
it { is_expected.to contain_class('zabbix::repo') }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/init.d/zabbix-agent') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d') }
it { is_expected.to contain_package('zabbix-agent') }
it { is_expected.to contain_service('zabbix-agent') }
it { is_expected.to contain_yumrepo('zabbix-nonsupported') }
it { is_expected.to contain_yumrepo('zabbix') }
it { is_expected.to contain_zabbix__startup('zabbix-agent') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_ensure('present') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_content %r{^UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive$} }
it { is_expected.to contain_class('zabbix::params') }
it { is_expected.to contain_class('zabbix::repo') }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/init.d/zabbix-agent') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf') }
it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d') }
it { is_expected.to contain_package('zabbix-agent') }
it { is_expected.to contain_service('zabbix-agent') }
it { is_expected.to contain_zabbix__startup('zabbix-agent') }
end
end
end
end

0 comments on commit f0eefee

Please sign in to comment.