forked from puppetlabs/puppetlabs-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_spec.rb
35 lines (31 loc) · 1.1 KB
/
db_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'spec_helper_acceptance'
describe 'postgresql::server::db', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'creates a database' do
begin
tmpdir = default.tmpdir('postgresql')
pp = <<-EOS
class { 'postgresql::server': }
postgresql::server::tablespace { 'postgresql_test_db':
location => '#{tmpdir}',
} ->
postgresql::server::db { 'postgresql_test_db':
user => 'test',
password => 'test1',
tablespace => 'postgresql_test_db',
}
EOS
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
psql('--command="select datname from pg_database" postgresql_test_db') do |r|
expect(r.stdout).to match(/postgresql_test_db/)
expect(r.stderr).to eq('')
end
psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test\'"') do |r|
expect(r.stdout).to match(/\(1 row\)/)
end
ensure
psql('--command="drop database postgresql_test_db" postgres')
psql('--command="DROP USER test"')
end
end
end