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
2ff84825
Commit
2ff84825
authored
May 23, 2013
by
Raphaël Pinson
Browse files
Add spec for postfix::config
parent
f3d4c00e
Changes
2
Hide whitespace changes
Inline
Side-by-side
manifests/config.pp
View file @
2ff84825
...
...
@@ -29,6 +29,11 @@
#
define
postfix::config
(
$value
,
$ensure
=
present
)
{
validate_string
(
$value
)
validate_string
(
$ensure
)
validate_re
(
$ensure
,
[
'present'
,
'absent'
],
"
\$
ensure must be either 'present' or 'absent', got '
${ensure}
'"
)
Augeas
{
incl
=>
'/etc/postfix/main.cf'
,
lens
=>
'Postfix_Main.lns'
,
...
...
spec/defines/postfix_config_spec.rb
0 → 100644
View file @
2ff84825
require
'spec_helper'
describe
'postfix::config'
do
let
(
:title
)
{
'foo'
}
let
(
:facts
)
{
{
:osfamily
=>
'Debian'
,
}
}
context
'when not passing value'
do
it
'should fail'
do
expect
{
should
contain_augeas
(
"set postfix 'foo'"
)
}.
to
raise_error
(
Puppet
::
Error
,
/Must pass value to Postfix::Config/
)
end
end
context
'when passing wrong type for value'
do
let
(
:params
)
{
{
:value
=>
[
'bar'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
"set postfix 'foo'"
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["bar"\] is not a string/
)
end
end
context
'when passing wrong type for ensure'
do
let
(
:params
)
{
{
:value
=>
'bar'
,
:ensure
=>
[
'present'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
"set postfix 'foo'"
)
}.
to
raise_error
(
Puppet
::
Error
,
/\["present"\] is not a string/
)
end
end
context
'when passing wrong value for ensure'
do
let
(
:params
)
{
{
:value
=>
'bar'
,
:ensure
=>
'running'
,
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
"set postfix 'foo'"
)
}.
to
raise_error
(
Puppet
::
Error
,
/must be either 'present' or 'absent'/
)
end
end
context
'when ensuring presence'
do
let
(
:params
)
{
{
:value
=>
'bar'
,
:ensure
=>
'present'
,
}
}
it
{
should
contain_augeas
(
"set postfix 'foo' to 'bar'"
).
with
(
:incl
=>
'/etc/postfix/main.cf'
,
:lens
=>
'Postfix_Main.lns'
,
:changes
=>
"set foo 'bar'"
)
}
end
context
'when ensuring absence'
do
let
(
:params
)
{
{
:value
=>
'bar'
,
:ensure
=>
'absent'
,
}
}
it
{
should
contain_augeas
(
"rm postfix 'foo'"
).
with
(
:incl
=>
'/etc/postfix/main.cf'
,
:lens
=>
'Postfix_Main.lns'
,
:changes
=>
"rm 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