Skip to content

Commit 7d168bc

Browse files
author
Ryan Coleman
committed
Merge pull request #15 from pdxcat/maint_add_missing_spec_tests
(#13073) Add missing puppet spec tests Reviewed by Ryan Coleman (ryan@puppetlabs.com) -- Thanks for the contributions!
2 parents b90860d + 05fcec5 commit 7d168bc

21 files changed

+375
-13
lines changed

Rakefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'rake'
2+
3+
task :default => [:spec]
4+
5+
desc "Run all module spec tests (Requires rspec-puppet gem)"
6+
task :spec do
7+
system("rspec spec")
8+
end
9+
10+
desc "Build package"
11+
task :build do
12+
system("puppet-module build")
13+
end
14+

manifests/dev.pp

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
class apache::dev {
1515
include apache::params
1616

17-
package{$apache::params::apache_dev: ensure => installed}
17+
package { "apache_dev_package":
18+
name => $apache::params::apache_dev,
19+
ensure => installed
20+
}
1821
}

manifests/init.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
class apache {
1616
include apache::params
17-
package { 'httpd':
17+
package { 'httpd':
1818
name => $apache::params::apache_name,
1919
ensure => installed,
2020
}
@@ -25,7 +25,8 @@
2525
subscribe => Package['httpd'],
2626
}
2727

28-
file { $apache::params::vdir:
28+
file { "httpd_vdir":
29+
name => $apache::params::vdir,
2930
ensure => directory,
3031
recurse => true,
3132
purge => true,

manifests/php.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
class apache::php {
1616
include apache::params
1717

18-
package { $apache::params::php_package:
18+
package { "apache_php_package":
19+
name => $apache::params::php_package,
1920
ensure => present,
2021
}
2122
}

manifests/python.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
include apache::params
1717
include apache
1818

19-
package { $apache::params::python_package:
19+
package { "apache_python_package":
20+
name => $apache::params::python_package,
2021
ensure => present,
2122
}
2223
a2mod { "python": ensure => present, }

manifests/ssl.pp

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
class apache::ssl {
1616

1717
include apache
18-
18+
1919
case $operatingsystem {
2020
'centos', 'fedora', 'redhat', 'scientific': {
21-
package { $apache::params::ssl_package:
21+
package { "apache_ssl_package":
22+
name => "$apache::params::ssl_package",
23+
ensure => installed,
2224
require => Package['httpd'],
2325
}
2426
}

manifests/vhost.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
}
6666
}
6767

68-
file {
69-
"${apache::params::vdir}/${priority}-${name}.conf":
68+
file { "${priority}-${name}.conf":
69+
name => "${apache::params::vdir}/${priority}-${name}.conf",
7070
content => template($template),
7171
owner => 'root',
7272
group => 'root',

manifests/vhost/proxy.pp

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# Configures an apache vhost that will only proxy requests
44
#
55
# Parameters:
6-
# * $port:
6+
# * $port:
77
# The port on which the vhost will respond
8-
# * $dest:
8+
# * $dest:
99
# URI that the requests will be proxied for
1010
# - $priority
1111
# - $template -- the template to use for the vhost
@@ -31,13 +31,16 @@
3131

3232
include apache
3333

34+
$apache_name = $apache::params::apache_name
35+
$ssl_path = $apache::params::ssl_path
3436
$srvname = $name
3537

3638
if $ssl == true {
3739
include apache::ssl
3840
}
3941

40-
file {"${apache::params::vdir}/${priority}-${name}":
42+
file { "${priority}-${name}":
43+
name => "${apache::params::vdir}/${priority}-${name}",
4144
content => template($template),
4245
owner => 'root',
4346
group => 'root',

manifests/vhost/redirect.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
$srvname = $name
3131

32-
file {"${apache::params::vdir}/${priority}-${name}":
32+
file { "${priority}-${name}":
33+
name => "${apache::params::vdir}/${priority}-${name}",
3334
content => template($template),
3435
owner => 'root',
3536
group => 'root',

spec/classes/apache_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'spec_helper'
2+
3+
describe 'apache', :type => :class do
4+
5+
it { should include_class("apache::params") }
6+
7+
it { should contain_package("httpd") }
8+
9+
it { should contain_service("httpd").with(
10+
'ensure' => 'running',
11+
'enable' => 'true',
12+
'subscribe' => 'Package[httpd]'
13+
)
14+
}
15+
16+
it { should contain_file("httpd_vdir").with(
17+
'ensure' => 'directory',
18+
'recurse' => 'true',
19+
'purge' => 'true',
20+
'notify' => 'Service[httpd]',
21+
'require' => 'Package[httpd]'
22+
)
23+
}
24+
end

spec/classes/dev_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::dev', :type => :class do
4+
5+
it { should include_class("apache::params") }
6+
it { should contain_package("apache_dev_package") }
7+
8+
end

spec/classes/mod/python_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::mod::python', :type => :class do
4+
5+
it { should include_class("apache") }
6+
7+
it { should contain_package("mod_python_package").with(
8+
'ensure' => 'installed',
9+
'require' => 'Package[httpd]'
10+
)
11+
}
12+
13+
it { should contain_a2mod("python").with(
14+
'ensure' => 'present'
15+
)
16+
}
17+
18+
end

spec/classes/mod/wsgi_spec.rb

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::mod::wsgi', :type => :class do
4+
5+
it { should include_class("apache") }
6+
7+
it { should contain_package("mod_wsgi_package").with(
8+
'require' => 'Package[httpd]'
9+
)
10+
}
11+
12+
it { should contain_a2mod("wsgi").with(
13+
'ensure' => 'present'
14+
)
15+
}
16+
17+
end

spec/classes/params_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::params', :type => :class do
4+
5+
it { should contain_apache__params }
6+
7+
# There are 4 resources in this class currently
8+
# there should not be any more resources because it is a params class
9+
# The resources are class[apache::params], class[main], class[settings], stage[main]
10+
it "Should not contain any resources" do
11+
subject.resources.size.should == 4
12+
end
13+
end

spec/classes/php_spec.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::php', :type => :class do
4+
5+
it { should include_class("apache::params") }
6+
it { should contain_package("apache_php_package") }
7+
8+
end

spec/classes/python_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::python', :type => :class do
4+
5+
it { should include_class("apache") }
6+
it { should include_class("apache::params") }
7+
it { should contain_package("apache_python_package") }
8+
it { should contain_a2mod("python").with(
9+
'ensure' => 'present'
10+
)
11+
}
12+
13+
end

spec/classes/ssl_spec.rb

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::ssl', :type => :class do
4+
5+
it { should include_class("apache") }
6+
it { should include_class("apache::params") }
7+
8+
describe "it should install the ssl package in redhat" do
9+
let :facts do
10+
{ :operatingsystem => 'redhat' }
11+
end
12+
13+
it { should contain_package("apache_ssl_package").with(
14+
'ensure' => 'installed'
15+
)
16+
}
17+
end
18+
19+
describe "it should contain a2mod ssl in debian" do
20+
let :facts do
21+
{ :operatingsystem => 'debian' }
22+
end
23+
24+
it { should contain_a2mod("ssl").with(
25+
'ensure' => 'present'
26+
)
27+
}
28+
end
29+
30+
end

spec/defines/vhost/proxy_spec.rb

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::vhost::proxy', :type => :define do
4+
5+
let :title do
6+
'my_proxy_vhost'
7+
end
8+
9+
10+
let :default_params do
11+
{
12+
:port => '80',
13+
:dest => 'example.com',
14+
:priority => '10',
15+
:template => "apache/vhost-proxy.conf.erb",
16+
:servername => '',
17+
:serveraliases => '',
18+
:ssl => false,
19+
:vhost_name => '*'
20+
}
21+
end
22+
23+
[{
24+
:dest => 'example2.com',
25+
:port => '80',
26+
:ssl => true
27+
},
28+
].each do |param_set|
29+
30+
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
31+
32+
let :param_hash do
33+
default_params.merge(param_set)
34+
end
35+
36+
let :params do
37+
param_set
38+
end
39+
40+
it { should include_class("apache") }
41+
it { should contain_apache__params }
42+
43+
it {
44+
if param_hash[:ssl]
45+
should contain_apache__ssl
46+
else
47+
should_not contain_apache__ssl
48+
end
49+
}
50+
51+
it { should contain_file("#{param_hash[:priority]}-#{title}").with({
52+
'owner' => 'root',
53+
'group' => 'root',
54+
'mode' => '755',
55+
'require' => 'Package[httpd]',
56+
'notify' => 'Service[httpd]'
57+
})
58+
}
59+
end
60+
end
61+
end

spec/defines/vhost/redirect_spec.rb

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
require 'spec_helper'
2+
3+
describe 'apache::vhost::redirect', :type => :define do
4+
let :title do
5+
'my_vhost_redirect'
6+
end
7+
8+
9+
let :default_params do
10+
{
11+
:port => '80',
12+
:dest => 'example.com',
13+
:priority => '10',
14+
:template => "apache/vhost-redirect.conf.erb",
15+
:vhost_name => '*'
16+
}
17+
end
18+
19+
[{
20+
:dest => 'example2.com',
21+
:port => '80',
22+
},
23+
].each do |param_set|
24+
25+
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
26+
27+
let :param_hash do
28+
default_params.merge(param_set)
29+
end
30+
31+
let :params do
32+
param_set
33+
end
34+
35+
it { should include_class("apache") }
36+
it { should contain_apache__params }
37+
38+
it { should contain_file("#{param_hash[:priority]}-#{title}").with({
39+
'owner' => 'root',
40+
'group' => 'root',
41+
'mode' => '755',
42+
'require' => 'Package[httpd]',
43+
'notify' => 'Service[httpd]'
44+
})
45+
}
46+
47+
# FIXME: Firewall is not actually realized anywhere
48+
#it { should contain_firewall("0100-INPUT ACCEPT #{param_hash[:port]}").with( {
49+
# 'jump' => 'Accept',
50+
# 'dport' => "#{param_hash[:port]}",
51+
# 'proto' => 'tcp'
52+
# })
53+
#}
54+
end
55+
end
56+
end

0 commit comments

Comments
 (0)