1 require 'spec_helper_acceptance'
3 describe 'postgresql_conn_validator', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
5 let(:install_pp) { <<-EOS
6 class { 'postgresql::server':
7 postgres_password => 'space password',
9 postgresql::server::role { 'testuser':
10 password_hash => postgresql_password('testuser','test1'),
12 postgresql::server::database { 'testdb':
14 require => Postgresql::Server::Role['testuser']
16 postgresql::server::database_grant { 'allow connect for testuser':
26 context 'local connection' do
27 it 'validates successfully with defaults' do
30 postgresql_conn_validator { 'validate this':
32 db_username => 'testuser',
33 db_password => 'test1',
35 psql_path => '/usr/bin/psql',
39 apply_manifest(pp, :catch_failures => true)
40 apply_manifest(pp, :catch_changes => true)
43 it 'works with connect settings hash' do
46 postgresql_conn_validator { 'validate this':
48 'PGDATABASE' => 'testdb',
50 'PGUSER' => 'testuser',
51 'PGPASSWORD' => 'test1',
52 'PGHOST' => 'localhost'
54 psql_path => '/usr/bin/psql'
58 apply_manifest(pp, :catch_failures => true)
59 apply_manifest(pp, :catch_changes => true)
63 it 'fails gracefully' do
66 postgresql_conn_validator { 'validate this':
67 psql_path => '/usr/bin/psql',
72 result = apply_manifest(pp)
73 expect(result.stderr).to match /Unable to connect to PostgreSQL server/