Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Puppet Camptocamp Postfix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Projets publics
Puppet Camptocamp Postfix
Commits
4172fa56
You need to sign in or sign up before continuing.
Commit
4172fa56
authored
May 27, 2013
by
Raphaël Pinson
Browse files
Options
Downloads
Patches
Plain Diff
Add spec for postfix::virtual
parent
ef37d24b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
manifests/virtual.pp
+8
-0
8 additions, 0 deletions
manifests/virtual.pp
spec/defines/postfix_virtual_spec.rb
+143
-0
143 additions, 0 deletions
spec/defines/postfix_virtual_spec.rb
with
151 additions
and
0 deletions
manifests/virtual.pp
+
8
−
0
View file @
4172fa56
...
@@ -39,6 +39,14 @@ define postfix::virtual (
...
@@ -39,6 +39,14 @@ define postfix::virtual (
)
{
)
{
include
postfix::augeas
include
postfix::augeas
validate_string
(
$destination
)
validate_string
(
$nexthop
)
validate_string
(
$file
)
validate_absolute_path
(
$file
)
validate_string
(
$ensure
)
validate_re
(
$ensure
,
[
'present'
,
'absent'
],
"
\$
ensure must be either 'present' or 'absent', got '
${ensure}
'"
)
case
$ensure
{
case
$ensure
{
'present'
:
{
'present'
:
{
$changes
=
[
$changes
=
[
...
...
This diff is collapsed.
Click to expand it.
spec/defines/postfix_virtual_spec.rb
0 → 100644
+
143
−
0
View file @
4172fa56
require
'spec_helper'
describe
'postfix::virtual'
do
let
(
:title
)
{
'foo'
}
let
(
:facts
)
{
{
:osfamily
=>
'Debian'
,
}
}
context
'when not sending destination'
do
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix virtual - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/Must pass destination/
)
end
end
context
'when sending wrong type for destination'
do
let
(
:params
)
{
{
:destination
=>
[
'bar'
],
}
}
it
'should fail'
do
expect
{
should
contain_augeas
(
'Postfix virtual - 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 virtual - 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 virtual - 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 virtual - 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 virtual - 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 virtual - foo'
)
}.
to
raise_error
(
Puppet
::
Error
,
/\$ensure must be either/
)
end
end
context
'when using default values'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
}
}
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix virtual - foo'
).
with
(
:incl
=>
'/etc/postfix/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"set pattern[. = 'foo']/destination 'bar'"
,
])
}
end
context
'when overriding default values'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:file
=>
'/tmp/virtual'
,
:ensure
=>
'present'
,
}
}
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix virtual - foo'
).
with
(
:incl
=>
'/tmp/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"set pattern[. = 'foo'] 'foo'"
,
"set pattern[. = 'foo']/destination 'bar'"
,
])
}
end
context
'when ensuring absence'
do
let
(
:params
)
{
{
:destination
=>
'bar'
,
:ensure
=>
'absent'
,
}
}
it
{
should
include_class
(
'postfix::augeas'
)
}
it
{
should
contain_augeas
(
'Postfix virtual - foo'
).
with
(
:incl
=>
'/etc/postfix/virtual'
,
:lens
=>
'Postfix_Virtual.lns'
,
:changes
=>
[
"rm pattern[. = 'foo']"
,
])
}
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment