-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change: * adds option notify_level * converts the template to epp * set all parameters type * Add rspec testing
- Loading branch information
Showing
4 changed files
with
80 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
require 'spec_helper' | ||
|
||
describe 'collectd::plugin::syslog', type: :class do | ||
on_supported_os(baseline_os_hash).each do |os, facts| | ||
context "on #{os} " do | ||
let :facts do | ||
facts | ||
end | ||
let :pre_condition do | ||
'include collectd' | ||
end | ||
|
||
options = os_specific_options(facts) | ||
|
||
context 'all options set' do | ||
let :params do | ||
{ | ||
log_level: 'debug', | ||
notify_level: 'FAILURE' | ||
} | ||
end | ||
|
||
content = <<EOS | ||
# Generated by Puppet | ||
<LoadPlugin syslog> | ||
Globals false | ||
</LoadPlugin> | ||
<Plugin syslog> | ||
LogLevel debug | ||
NotifyLevel FAILURE | ||
</Plugin> | ||
EOS | ||
|
||
it "Will create #{options[:plugin_conf_dir]}/05-syslog.conf" do | ||
is_expected.to contain_file('syslog.load').with( | ||
ensure: 'present', | ||
path: "#{options[:plugin_conf_dir]}/05-syslog.conf", | ||
content: content | ||
) | ||
end | ||
end | ||
|
||
context ':ensure => absent' do | ||
let :params do | ||
{ ensure: 'absent' } | ||
end | ||
|
||
it "Will not create #{options[:plugin_conf_dir]}/05-syslog.conf" do | ||
is_expected.to contain_file('syslog.load').with( | ||
ensure: 'absent', | ||
path: "#{options[:plugin_conf_dir]}/05-syslog.conf" | ||
) | ||
end | ||
end | ||
|
||
context 'notify_level invalid' do | ||
let :params do | ||
{ notify_level: 'notexist' } | ||
end | ||
|
||
it 'Will raise an error about :notify_level being Enum' do | ||
is_expected.to compile.and_raise_error(%r{Enum}) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Plugin syslog> | ||
LogLevel <%= $collectd::plugin::syslog::log_level %> | ||
<% if $collectd::plugin::syslog::notify_level { -%> | ||
NotifyLevel <%= $collectd::plugin::syslog::notify_level %> | ||
<% } -%> | ||
</Plugin> |
This file was deleted.
Oops, something went wrong.