|
| 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 |
0 commit comments