Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Puppet Camptocamp Postfix
Commits
803c088f
Commit
803c088f
authored
May 27, 2013
by
Raphaël Pinson
Browse files
Add spec for postfix::transport
parent
68f789a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
manifests/transport.pp
View file @
803c088f
...
...
@@ -39,6 +39,12 @@ define postfix::transport (
)
{
include
postfix::augeas
validate_string
(
$destination
)
validate_string
(
$nexthop
)
validate_string
(
$file
)
validate_absolute_path
(
$file
)
validate_string
(
$ensure
)
case
$ensure
{
'present'
:
{
if
(
$destination
)
{
...
...
@@ -65,7 +71,7 @@ define postfix::transport (
}
default
:
{
fail
(
"Wrong ensure value:
${ensure}
"
)
fail
"
\$
ensure must be either 'present' or 'absent', got '
${ensure}
'
"
}
}
...
...
spec/defines/postfix_transport_spec.rb
0 → 100644
View file @
803c088f
require
'spec_helper'
describe
'postfix::transport'
do
let
(
:title
)
{
'foo'
}
let
(
:facts
)
{
{
:osfamily
=>
'Debian'
,
}
}
context
'when sending wrong type for destination'
do
let
(
:params
)
{
{
:destination
=>
[
'bar'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["bar"\] is not a string/
)
end
end
context
'when sending wrong type for nexthop'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:nexthop
=>
[
'baz'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["baz"\] is not a string/
)
end
end
context
'when sending wrong type for file'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:file
=>
[
'baz'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["baz"\] is not a string/
)
end
end
context
'when sending wrong value for file'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:file
=>
'baz'
,
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/"baz" is not an absolute path/
)
end
end
context
'when sending wrong type for ensure'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:ensure
=>
[
'baz'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["baz"\] is not a string/
)
end
end
context
'when sending wrong value for ensure'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:ensure
=>
'running'
,
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix transport - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\$ensure must be either/
)
end
end
context
'when using default values'
do
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix transport - foo'
).
with
(
:incl
=>
'/etc/postfix/transport'
,
:lens
=>
'Postfix_Transport.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"clear pattern[. = 'foo']/transport"
,
"clear pattern[. = 'foo']/nexthop"
,
])
}
end
context
'when overriding default values'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:nexthop
=>
'baz'
,
:file
=>
'/tmp/transport'
,
:ensure
=>
'present'
,
}
}
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix transport - foo'
).
with
(
:incl
=>
'/tmp/transport'
,
:lens
=>
'Postfix_Transport.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"set pattern[. = 'foo']/transport 'bar'"
,
"set pattern[. = 'foo']/nexthop 'baz'"
,
])
}
end
context
'when ensuring absence'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:ensure
=>
'absent'
,
}
}
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix transport - foo'
).
with
(
:incl
=>
'/etc/postfix/transport'
,
:lens
=>
'Postfix_Transport.lns'
,
:changes
=>
[
"rm pattern[. = 'foo']"
,
])
}
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment