Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance testing #302

Merged
merged 8 commits into from
Oct 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ Style/AndOr:
Style/RedundantSelf:
Enabled: True

Style/BlockLength:
Enabled: False

# Method length is not necessarily an indicator of code quality
Metrics/MethodLength:
Enabled: False
Expand Down
2 changes: 0 additions & 2 deletions .sync.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
.travis.yml:
secure: "ijm7hKPYWr1eg7151g5oK6MzZL4ojrgWjKlxgoBHXAdXdY88opMgvixfSJK5IMUbtanPfWRkqqABx+MYO78nfQBWDlghUzZ8sQXFeO2Ie0PgWl4nFV0kKWz+ejVaZC4dKSZlWha5pO1ek+sx7KnjIBZY82OXs/GXbjwhHx6d56YugXLuCyvfFxC7mXC9wF58bPwcYRCBSZt9CRl0OMBAFybxjdwsFMloRRhdz7f3hhlqF8Nrs1sxG1HhgiMcnrZqovNfb3Tw9K1RPYATazXxQrjcI7YHvJx0AvtHFUsn+/A0GtpKUuuPbaVdkYgE1Tye0AsAcey6RW4xhJywZglKrzDk7vfyUiU5CObeLh4/dhub3k111rDPL8v6v9t40fteduJoFLziHotQwdl37UALL7PwWZY5HuJvaBqHY2LsGs/ptGMB9ZCzxA85jfDw8lrZQ7P97SAoC34Ihs8D6vkKT9HUKHIXh19O5AAa70jReru0ej179IBjvs8m9nDwDNdY3sIsdhUU8WQ3BftDF6M8OzvgyLKDvjSs1Izag+Asl2Ze7RAQfQ2RvbfkDm9KEFnDQtXtzF4Cu1Ed6io2j1zI71JFQpIf6zb1qeNrhqulbJ15owGkQmHBgD8K+bDd1CCU4kA26axypV00XDsjfwdtFHgtUO3AlUVUim0QTMk9ATc="
spec/spec_helper.rb:
spec_overrides: "require 'spec_helper_methods'"
40 changes: 33 additions & 7 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
on_supported_os.each do |os, facts|
context "on #{os} " do
systemd_fact = case facts[:osfamily]
when 'Archlinux'
when 'Archlinux', 'Fedora'
{ systemd: true }
else
{ systemd: false }
end
config_path = case facts[:operatingsystem]
when 'Fedora'
'/etc/zabbix_agentd.conf'
else
'/etc/zabbix/zabbix_agentd.conf'
end
let :facts do
facts.merge(
mocked_facts
).merge(
systemd_fact
)
facts.merge(systemd_fact)
end

context 'with all defaults' do
Expand Down Expand Up @@ -56,6 +58,8 @@

it { should contain_file('/etc/zabbix/zabbix_agentd.d').with_ensure('directory') }
it { should contain_zabbix__startup('zabbix-agent').that_requires("Package[#{package}]") }
it { should compile.with_all_deps }
it { should contain_class('zabbix::params') }
end

context 'when declaring manage_repo is true' do
Expand Down Expand Up @@ -91,7 +95,19 @@
}
end

it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^HostnameItem=system.hostname$} }
it { should contain_file(config_path).with_content %r{^HostnameItem=system.hostname$} }
end

context 'ignores hostnameitem if hostname is set' do
let :params do
{
hostname: 'test',
hostnameitem: 'system.hostname'
}
end

it { should contain_file(config_path).without_content %r{^HostnameItem=system.hostname$} }
it { should contain_file(config_path).with_content %r{^Hostname=test$} }
end

context 'when declaring manage_firewall is true' do
Expand All @@ -114,6 +130,16 @@
it { should_not contain_firewall('150 zabbix-agent') }
end

context 'it creates a startup script' do
case facts[:osfamily]
when 'Archlinux', 'Fedora'
it { should contain_file('/etc/init.d/zabbix-agent').with_ensure('absent') }
it { should contain_file('/etc/systemd/system/zabbix-agent.service').with_ensure('file') }
else
it { should contain_file('/etc/init.d/zabbix-agent').with_ensure('file') }
it { should_not contain_file('/etc/systemd/system/zabbix-agent.service') }
end
end
context 'configuration file with full options' do
let :params do
{
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/database_mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts.merge(
mocked_facts
)
facts
end
context 'with all defaults' do
it 'fails' do
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/sender_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts.merge(
mocked_facts
)
facts
end
context 'with all defaults' do
it { should contain_class('zabbix::sender') }
Expand Down
6 changes: 1 addition & 5 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
{ systemd: false }
end
let :facts do
facts.merge(
mocked_facts
).merge(
systemd_fact
)
facts.merge(systemd_fact)
end

describe 'with default settings' do
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/userparameter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts.merge(
mocked_facts
)
facts
end
context 'with all defaults' do
it { should contain_class('zabbix::userparameter') }
Expand Down
4 changes: 1 addition & 3 deletions spec/classes/web_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ def package_provider_for_gems
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts.merge(
mocked_facts
)
facts
end

if facts[:osfamily] == 'Archlinux'
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/startup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'zabbix::startup', type: :define do # rubocop:disable RSpec/MultipleDescribes
let(:title) { 'zabbix-agent' }

%w(RedHat Debian Gentoo).each do |osfamily|
%w(RedHat Debian Gentoo Archlinux).each do |osfamily|
context "on #{osfamily}" do
context 'on legacy init systems' do
['false', false].each do |systemd_fact_state|
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
c.default_facts = default_facts
end

require 'spec_helper_methods'
# vim: syntax=ruby
7 changes: 0 additions & 7 deletions spec/spec_helper_methods.rb

This file was deleted.