Skip to content

Commit 1c5e7c7

Browse files
committed
specs
1 parent ae16b8e commit 1c5e7c7

9 files changed

+105
-29
lines changed

Gemfile.lock

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ GEM
1616
puppet-lint (~> 0.3)
1717
puppetlabs_spec_helper (~> 0.4)
1818
rspec-puppet (~> 0.1)
19-
diff-lcs (1.2.4)
20-
facter (1.7.2)
19+
diff-lcs (1.2.5)
20+
facter (1.7.3)
2121
faraday (0.8.8)
2222
multipart-post (~> 1.2.0)
2323
faraday_middleware (0.9.0)
2424
faraday (>= 0.7.4, < 0.9)
2525
hashie (2.0.5)
2626
hiera (1.2.1)
2727
json_pure
28-
highline (1.6.19)
29-
json (1.8.0)
30-
json_pure (1.8.0)
28+
highline (1.6.20)
29+
json (1.8.1)
30+
json_pure (1.8.1)
3131
librarian-puppet (0.9.10)
3232
json
3333
thor (~> 0.15)
3434
metaclass (0.0.1)
3535
mocha (0.14.0)
3636
metaclass (~> 0.0.1)
37-
multi_json (1.7.9)
37+
multi_json (1.8.2)
3838
multipart-post (1.2.0)
3939
netrc (0.7.7)
4040
octokit (1.25.0)
@@ -44,7 +44,7 @@ GEM
4444
hashie (~> 2.0)
4545
multi_json (~> 1.3)
4646
netrc (~> 0.7.7)
47-
puppet (3.2.4)
47+
puppet (3.3.2)
4848
facter (~> 1.6)
4949
hiera (~> 1.0)
5050
rgen (~> 0.6.5)
@@ -55,15 +55,15 @@ GEM
5555
rspec (>= 2.9.0)
5656
rspec-puppet (>= 0.1.1)
5757
rake (10.1.0)
58-
rgen (0.6.5)
58+
rgen (0.6.6)
5959
rspec (2.14.1)
6060
rspec-core (~> 2.14.0)
6161
rspec-expectations (~> 2.14.0)
6262
rspec-mocks (~> 2.14.0)
63-
rspec-core (2.14.5)
64-
rspec-expectations (2.14.2)
63+
rspec-core (2.14.7)
64+
rspec-expectations (2.14.4)
6565
diff-lcs (>= 1.1.3, < 2.0)
66-
rspec-mocks (2.14.3)
66+
rspec-mocks (2.14.4)
6767
rspec-puppet (0.1.6)
6868
rspec
6969
thor (0.18.1)

manifests/config.pp

+7-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
$logdir
2424
]:
2525
ensure => $dir_ensure;
26-
27-
'/Library/LaunchDaemons/dev.postgresql.plist':
28-
content => template('postgresql/dev.postgresql.plist.erb'),
29-
group => 'wheel',
30-
owner => 'root' ;
3126
}
3227

3328
sysctl::set {
@@ -48,5 +43,12 @@
4843
file { "${boxen::config::envdir}/postgresql.sh":
4944
ensure => absent,
5045
}
46+
47+
48+
file { '/Library/LaunchDaemons/dev.postgresql.plist':
49+
content => template('postgresql/dev.postgresql.plist.erb'),
50+
group => 'wheel',
51+
owner => 'root',
52+
}
5153
}
5254
}

manifests/service.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Internal: manages postgresql service
22
class postgresql::service(
3-
$ensure = postgresql::params::ensure,
3+
$ensure = $postgresql::params::ensure,
44

55
$service = $postgresql::params::service,
66
$enable = $postgresql::params::enable,
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
require 'spec_helper'
2+
3+
describe 'postgresql::config' do
4+
let(:facts) { default_test_facts }
5+
6+
it do
7+
should include_class('boxen::config')
8+
9+
%w(data/postgresql log/postgresql).each do |d|
10+
should contain_file("/test/boxen/#{d}").with_ensure(:directory)
11+
end
12+
13+
contain_sysctl__set("kern.sysv.shmmax")
14+
contain_sysctl__set("kern.sysv.shmall")
15+
16+
should include_class("boxen::config")
17+
should contain_boxen__env_script("postgresql")
18+
should contain_file("/Library/LaunchDaemons/dev.postgresql.plist")
19+
end
20+
21+
context "Ubuntu" do
22+
let(:facts) { default_test_facts.merge(:operatingsystem => "Ubuntu") }
23+
24+
it do
25+
should_not include_class("boxen::config")
26+
27+
should_not contain_boxen__env_script("postgresql")
28+
should_not contain_file("/Library/LaunchDaemons/dev.postgresql.plist")
29+
end
30+
end
31+
end
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require "spec_helper"
2+
3+
describe "postgresql::package" do
4+
let(:facts) { default_test_facts }
5+
6+
it do
7+
should contain_homebrew__formula("postgresql")
8+
9+
should contain_package("boxen/brews/postgresql")
10+
end
11+
12+
context "Ubuntu" do
13+
let(:facts) { default_test_facts.merge(:operatingsystem => "Ubuntu") }
14+
15+
it do
16+
should_not contain_homebrew__formula("postgresql")
17+
18+
should contain_package("postgresql-server-9.1")
19+
end
20+
end
21+
end
22+
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require "spec_helper"
2+
3+
describe "postgresql::service" do
4+
let(:facts) { default_test_facts }
5+
6+
it do
7+
should contain_service("com.boxen.postgresql").with_ensure(:stopped)
8+
9+
should contain_exec("init-postgresql-db").with_creates("/test/boxen/data/postgresql/PG_VERSION")
10+
should contain_service("dev.postgresql").with_ensure(:running)
11+
should contain_exec("wait-for-postgresql").with_unless("nc -z 127.0.0.1 15432")
12+
end
13+
14+
context "Ubuntu" do
15+
let(:facts) { default_test_facts.merge(:operatingsystem => "Ubuntu") }
16+
17+
it do
18+
should_not contain_service("com.boxen.postgresql")
19+
20+
should contain_exec("init-postgresql-db").with_creates("/var/lib/postgresql/PG_VERSION")
21+
should contain_service("postgresql-9.1").with_ensure(:running)
22+
should contain_exec("wait-for-postgresql").with_unless("nc -z 127.0.0.1 5432")
23+
end
24+
end
25+
end
26+

spec/classes/postgresql_config_spec.rb

-9
This file was deleted.

spec/classes/postgresql_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
let(:facts) { default_test_facts }
55

66
it do
7-
7+
should contain_class("postgresql::config")
8+
should contain_class("postgresql::package")
9+
should contain_class("postgresql::service")
810
end
911
end

spec/spec_helper.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010
def default_test_facts
1111
{
12-
:boxen_home => "/test/boxen",
13-
:boxen_user => "testuser"
12+
:boxen_home => "/test/boxen",
13+
:boxen_user => "testuser",
14+
:ipaddress_lo0 => "127.0.0.1",
15+
:operatingsystem => "Darwin",
1416
}
1517
end

0 commit comments

Comments
 (0)