Skip to content

Commit

Permalink
Add validation and spec for pipe transport
Browse files Browse the repository at this point in the history
This builds on work already merged for supporting the pipe transport. It
provides validation that the pipe is a hash and adds a spec. This makes
the pipe property's implementation more consistent with other properties.
  • Loading branch information
yeungda committed Sep 12, 2014
1 parent f16bfaf commit ef147bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion manifests/handler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
validate_re($ensure, ['^present$', '^absent$'] )
validate_re($type, [ '^pipe$', '^tcp$', '^udp$', '^amqp$', '^set$', '^transport$' ] )
if $exchange { validate_hash($exchange) }
if $pipe { validate_hash($pipe) }
if $socket { validate_hash($socket) }
validate_array($severities)
if $source { validate_re($source, ['^puppet://'] ) }
Expand All @@ -95,7 +96,7 @@
fail('exchange must be set with type amqp')
}

if $type == 'transport' and !pipe {
if $type == 'transport' and !$pipe {
fail('pipe must be set with type transport')
}

Expand Down
24 changes: 24 additions & 0 deletions spec/defines/sensu_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@
it { should contain_sensu_handler('myhandler').with_socket({'host' => '192.168.23.23', 'port' => '2003'}) }
end

context 'transport' do
let(:params) {
{
:type => 'transport',
:pipe => {
'type' => 'topic',
'name' => 'events',
'options' => {
'passive' => 'true',
'durable' => 'true'
}
}
}
}
it { should contain_sensu_handler('myhandler').with_pipe({
'type' => 'topic',
'name' => 'events',
'options' => {
'passive' => 'true',
'durable' => 'true'
}
}) }
end

context 'mutator' do
let(:params) { { :mutator => 'only_check_output' } }

Expand Down

0 comments on commit ef147bd

Please sign in to comment.