Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit 255acda

Browse files
committed
Merge pull request #12 from boxen/tests
Needs tests
2 parents 5b03457 + 691450f commit 255acda

File tree

18 files changed

+211
-20
lines changed

18 files changed

+211
-20
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
script: "./script/cibuild"
33
gemfile: "this/does/not/exist"
44
rvm:
5-
- "1.8.7"
5+
- "1.8.7"
6+
- "1.9.3"

Gemfile.lock

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GEM
33
specs:
44
addressable (2.3.5)
55
ansi (1.4.3)
6-
boxen (1.4.2)
6+
boxen (1.5.2)
77
ansi (~> 1.4)
88
hiera (~> 1.0)
99
highline (~> 1.6)
@@ -17,9 +17,9 @@ GEM
1717
puppetlabs_spec_helper (~> 0.4)
1818
rspec-puppet (~> 0.1)
1919
diff-lcs (1.2.4)
20-
facter (1.7.1)
21-
faraday (0.8.7)
22-
multipart-post (~> 1.1)
20+
facter (1.7.2)
21+
faraday (0.8.8)
22+
multipart-post (~> 1.2.0)
2323
faraday_middleware (0.9.0)
2424
faraday (>= 0.7.4, < 0.9)
2525
hashie (2.0.5)
@@ -28,26 +28,26 @@ GEM
2828
highline (1.6.19)
2929
json (1.8.0)
3030
json_pure (1.8.0)
31-
librarian-puppet (0.9.9)
31+
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.7)
37+
multi_json (1.7.9)
3838
multipart-post (1.2.0)
3939
netrc (0.7.7)
40-
octokit (1.24.0)
40+
octokit (1.25.0)
4141
addressable (~> 2.2)
4242
faraday (~> 0.8)
4343
faraday_middleware (~> 0.9)
4444
hashie (~> 2.0)
4545
multi_json (~> 1.3)
4646
netrc (~> 0.7.7)
47-
puppet (3.2.2)
47+
puppet (3.2.4)
4848
facter (~> 1.6)
4949
hiera (~> 1.0)
50-
rgen (~> 0.6)
50+
rgen (~> 0.6.5)
5151
puppet-lint (0.3.2)
5252
puppetlabs_spec_helper (0.4.1)
5353
mocha (>= 0.10.5)
@@ -56,14 +56,14 @@ GEM
5656
rspec-puppet (>= 0.1.1)
5757
rake (10.1.0)
5858
rgen (0.6.5)
59-
rspec (2.13.0)
60-
rspec-core (~> 2.13.0)
61-
rspec-expectations (~> 2.13.0)
62-
rspec-mocks (~> 2.13.0)
63-
rspec-core (2.13.1)
64-
rspec-expectations (2.13.0)
59+
rspec (2.14.1)
60+
rspec-core (~> 2.14.0)
61+
rspec-expectations (~> 2.14.0)
62+
rspec-mocks (~> 2.14.0)
63+
rspec-core (2.14.5)
64+
rspec-expectations (2.14.2)
6565
diff-lcs (>= 1.1.3, < 2.0)
66-
rspec-mocks (2.13.1)
66+
rspec-mocks (2.14.3)
6767
rspec-puppet (0.1.6)
6868
rspec
6969
thor (0.18.1)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ postgresql::db { 'mydb': }
2020
* `sysctl`
2121

2222
*Note: Boxen runs most services on non-standard ports as to not collide with existing local installs. Boxen Postgresql runs on 15432 as opposed to the standard 5432.*
23+
24+
Then write some code. Run `script/cibuild` to test it. Check the `script`
25+
directory for other useful tools.

manifests/config.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Internal: Configure postgresql.
2+
#
3+
# Examples
4+
#
5+
# include postgresql::config
16
class postgresql::config {
27
require boxen::config
38

manifests/db.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Creates a new postgresql database.
2+
#
3+
# Usage:
4+
#
5+
# postgresql::db { 'mydb': }
16
define postgresql::db($ensure = present) {
27
require postgresql
38

@@ -6,7 +11,7 @@
611
'createdb',
712
"-p${postgresql::config::port}",
813
'-E UTF-8',
9-
"-O ${::luser}",
14+
"-O ${::boxen_user}",
1015
$name
1116
], ' '),
1217
require => Exec['wait-for-postgresql'],

manifests/init.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Public: Install and configure postgresql from homebrew.
2+
#
3+
# Examples
4+
#
5+
# include postgresql
16
class postgresql {
27
include postgresql::config
38
include homebrew
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
end
9+
end

spec/classes/postgresql_spec.rb

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
require 'spec_helper'
2+
3+
describe 'postgresql' do
4+
let(:facts) { default_test_facts }
5+
6+
it do
7+
should include_class('postgresql::config')
8+
should include_class('homebrew')
9+
should include_class('sysctl')
10+
11+
['data', 'log'].each do |dir|
12+
should contain_file("/test/boxen/#{dir}/postgresql").with({
13+
:ensure => 'directory',
14+
})
15+
end
16+
17+
should contain_file('/Library/LaunchDaemons/dev.postgresql.plist').with({
18+
:content => File.read('spec/fixtures/dev.postgresql.plist'),
19+
:group => 'wheel',
20+
:notify => 'Service[dev.postgresql]',
21+
:owner => 'root',
22+
})
23+
24+
should contain_sysctl__set('kern.sysv.shmmax').with({
25+
:value => 1610612736
26+
})
27+
28+
should contain_sysctl__set('kern.sysv.shmall').with({
29+
:value => 393216
30+
})
31+
32+
should contain_homebrew__formula('postgresql').
33+
with_before('Package[boxen/brews/postgresql]')
34+
35+
should contain_package('boxen/brews/postgresql').with({
36+
:ensure => '9.2.4-boxen2',
37+
:notify => 'Service[dev.postgresql]'
38+
})
39+
40+
should contain_exec('init-postgresql-db').with({
41+
:command => 'initdb -E UTF-8 /test/boxen/data/postgresql',
42+
:creates => '/test/boxen/data/postgresql/PG_VERSION',
43+
:require => 'Package[boxen/brews/postgresql]'
44+
})
45+
46+
should contain_service('dev.postgresql').with({
47+
:ensure => 'running',
48+
:require => 'Exec[init-postgresql-db]'
49+
})
50+
51+
should contain_service('com.boxen.postgresql').with({
52+
:ensure => nil,
53+
:before => 'Service[dev.postgresql]'
54+
})
55+
56+
should contain_file('/test/boxen/env.d/postgresql.sh').with({
57+
:content => File.read('spec/fixtures/postgresql.sh'),
58+
:require => 'File[/test/boxen/env.d]'
59+
})
60+
61+
should contain_exec('wait-for-postgresql').with({
62+
:command => 'while ! nc -z localhost 15432; do sleep 1; done',
63+
:provider => 'shell',
64+
:timeout => 30,
65+
:unless => 'nc -z localhost 15432',
66+
:require => 'Service[dev.postgresql]'
67+
})
68+
end
69+
end

spec/defines/postgresql_db_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper'
2+
3+
describe "postgresql::db" do
4+
let(:facts) { default_test_facts }
5+
let(:title) { 'testdb' }
6+
7+
it do
8+
should include_class("postgresql")
9+
10+
should contain_exec("postgresql-db-#{title}").with({
11+
:command => "createdb -p15432 -E UTF-8 -O testuser #{title}",
12+
:require => 'Exec[wait-for-postgresql]',
13+
:unless => "psql -aA -p15432 -t -l | cut -d \\| -f 1 | grep -w '#{title}'"
14+
})
15+
end
16+
end

spec/fixtures/Puppetfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mod 'boxen', '3.0.2', :github_tarball => 'boxen/puppet-boxen'
2+
mod 'homebrew', '1.4.1', :github_tarball => "boxen/puppet-homebrew"
3+
mod 'respository', '2.2.0', :github_tarball => "boxen/puppet-repository"
4+
mod 'stdlib', '4.1.0', :github_tarball => "puppetlabs/puppetlabs-stdlib"
5+
mod 'sysctl', '1.0.0', :github_tarball => "boxen/puppet-sysctl"

0 commit comments

Comments
 (0)