Skip to content

Commit 1c81250

Browse files
author
Joshua Hoblitt
committed
add tests for pureftpd::{install,params,service}
1 parent 187c3f0 commit 1c81250

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

manifests/install.pp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class pureftpd::install (
77
$use_selinux = false,
88
) inherits pureftpd::params {
9+
validate_bool($use_selinux)
910

1011
if ($use_selinux) {
1112
$package_name = $pureftpd::params::package_name_selinux

spec/classes/install_spec.rb

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
describe 'pureftpd::install', :type => :class do
4+
describe 'for osfamily RedHat' do
5+
let(:facts) {{ :osfamily => 'RedHat' }}
6+
7+
describe 'no params' do
8+
it { should include_class('pureftpd::install') }
9+
it { should contain_package('pure-ftpd').with_ensure('present') }
10+
it { should_not contain_package('pure-ftpd-selinux').with_ensure('present') }
11+
end
12+
13+
describe 'use_selinux = false' do
14+
let(:params) {{ :use_selinux => false }}
15+
16+
it { should include_class('pureftpd::install') }
17+
it { should contain_package('pure-ftpd').with_ensure('present') }
18+
it { should_not contain_package('pure-ftpd-selinux').with_ensure('present') }
19+
end
20+
21+
describe 'use_selinux = true' do
22+
let(:params) {{ :use_selinux => true }}
23+
24+
it { should include_class('pureftpd::install') }
25+
it { should contain_package('pure-ftpd').with_ensure('present') }
26+
it { should contain_package('pure-ftpd-selinux').with_ensure('present') }
27+
end
28+
29+
describe 'use_selinux = foo' do
30+
let(:params) {{ :use_selinux => 'foo' }}
31+
32+
it 'should fail' do
33+
expect { should include_class('pureftpd::install') }.
34+
to raise_error(Puppet::Error, /not a boolean/)
35+
end
36+
end
37+
end
38+
39+
end

spec/classes/params_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'spec_helper'
2+
3+
describe 'pureftpd::params', :type => :class do
4+
describe 'for osfamily RedHat' do
5+
let(:facts) {{ :osfamily => 'RedHat' }}
6+
7+
it { should include_class('pureftpd::params') }
8+
end
9+
10+
describe 'unsupported osfamily' do
11+
let :facts do
12+
{
13+
:osfamily => 'Debian',
14+
:operatingsystem => 'Debian',
15+
}
16+
end
17+
18+
it 'should fail' do
19+
expect { should include_class('pureftpd::params') }.
20+
to raise_error(Puppet::Error, /not supported on Debian/)
21+
end
22+
end
23+
24+
end

spec/classes/service_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'spec_helper'
2+
3+
describe 'pureftpd::service', :type => :class do
4+
let(:facts) {{ :osfamily => 'RedHat' }}
5+
6+
it do
7+
should contain_service('pure-ftpd').with({
8+
:hasstatus => 'true',
9+
:hasrestart => 'true',
10+
:enable => 'true',
11+
})
12+
end
13+
14+
end
15+

0 commit comments

Comments
 (0)