Skip to content

Commit

Permalink
Merge branch 'dependency_duration'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobapple committed Feb 21, 2017
2 parents 76112e9 + 408aa74 commit 38edc0a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifests/object/notification.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
if !is_string($user_groups) { validate_array($user_groups) }
if $times { validate_hash ($times )}
if $command { validate_string ($command )}
if $interval { validate_integer ($interval )}
if $interval { validate_re($interval, '^\d+(\.\d+)?[dhms]?$')}
if $period { validate_string ($period )}
if $zone { validate_string ($zone) }
if !is_array($types) { validate_string($types) }
Expand Down
2 changes: 1 addition & 1 deletion manifests/object/scheduleddowntime.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
if $author { validate_string($author) }
if $comment { validate_string($comment) }
if $fixed { validate_bool($fixed) }
if $duration { validate_integer($duration) }
if $duration { validate_re($duration, '^\d+(\.\d+)?[dhms]?$') }
if $ranges { validate_hash($ranges) }

# compose attributes
Expand Down
24 changes: 21 additions & 3 deletions spec/defines/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,19 @@
end


context "#{os} with interval => 30m" do
let(:params) { {:interval => '30m', :target => '/bar/baz'} }

it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar')
.with({'target' => '/bar/baz'})
.with_content(/interval = 30m/) }
end


context "#{os} with interval => foo (not a valid integer)" do
let(:params) { {:interval => 'foo', :target => '/bar/baz'} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) }
end


Expand Down Expand Up @@ -328,10 +337,19 @@
end


context "Windows 2012 R2 with interval => 30m" do
let(:params) { {:interval => '30m', :target => 'C:/bar/baz'} }

it { is_expected.to contain_concat__fragment('icinga2::object::Notification::bar')
.with({'target' => 'C:/bar/baz'})
.with_content(/interval = 30m/) }
end


context "Windows 2012 R2 with interval => foo (not a valid integer)" do
let(:params) { {:interval => 'foo', :target => 'C:/bar/baz'} }
let(:params) { {:interval => 'foo', :target => '/bar/baz'} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) }
end


Expand Down
32 changes: 29 additions & 3 deletions spec/defines/scheduleddowntime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,27 @@
end


context "#{os} with duration => 30m" do
let(:params) { {:duration => '30m', :target => '/bar/baz',
:host_name => 'foohost',
:author => 'fooauthor',
:comment => 'foocomment',
:ranges => { 'foo' => "bar", 'bar' => "foo"}} }

it { is_expected.to contain_concat__fragment('icinga2::object::ScheduledDowntime::bar')
.with({'target' => '/bar/baz'})
.with_content(/duration = 30m/) }
end


context "#{os} with duration => foo (not a valid integer)" do
let(:params) { {:duration => 'foo', :target => '/bar/baz',
:host_name => 'foohost',
:author => 'fooauthor',
:comment => 'foocomment',
:ranges => { 'foo' => "bar", 'bar' => "foo"}} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) }
end


Expand Down Expand Up @@ -274,14 +287,27 @@
end


context "Windows 2012 R2 with duration => 30m" do
let(:params) { {:duration => '30m', :target => 'C:/bar/baz',
:host_name => 'foohost',
:author => 'fooauthor',
:comment => 'foocomment',
:ranges => { 'foo' => "bar", 'bar' => "foo"}} }

it { is_expected.to contain_concat__fragment('icinga2::object::ScheduledDowntime::bar')
.with({'target' => 'C:/bar/baz'})
.with_content(/duration = 30m/) }
end


context "Windows 2012 R2 with duration => foo (not a valid integer)" do
let(:params) { {:duration => 'foo', :target => 'C:/bar/baz',
let(:params) { {:duration => 'foo', :target => '/bar/baz',
:host_name => 'foohost',
:author => 'fooauthor',
:comment => 'foocomment',
:ranges => { 'foo' => "bar", 'bar' => "foo"}} }

it { is_expected.to raise_error(Puppet::Error, /first argument to be an Integer/) }
it { is_expected.to raise_error(Puppet::Error, /"foo" does not match/) }
end


Expand Down

0 comments on commit 38edc0a

Please sign in to comment.