|
4 | 4 |
|
5 | 5 | describe 'postgresql::server::db' do
|
6 | 6 | it 'creates a database' do
|
7 |
| - begin |
8 |
| - tmpdir = run_shell('mktemp').stdout |
9 |
| - pp = <<-MANIFEST |
10 |
| - class { 'postgresql::server': |
11 |
| - postgres_password => 'space password', |
12 |
| - } |
13 |
| - postgresql::server::tablespace { 'postgresql-test-db': |
14 |
| - location => '#{tmpdir}', |
15 |
| - } -> |
16 |
| - postgresql::server::db { 'postgresql-test-db': |
17 |
| - comment => 'testcomment', |
18 |
| - user => 'test-user', |
19 |
| - password => 'test1', |
20 |
| - tablespace => 'postgresql-test-db', |
21 |
| - } |
22 |
| - MANIFEST |
| 7 | + tmpdir = run_shell('mktemp').stdout |
| 8 | + pp = <<-MANIFEST |
| 9 | + class { 'postgresql::server': |
| 10 | + postgres_password => 'space password', |
| 11 | + } |
| 12 | + postgresql::server::tablespace { 'postgresql-test-db': |
| 13 | + location => '#{tmpdir}', |
| 14 | + } -> |
| 15 | + postgresql::server::db { 'postgresql-test-db': |
| 16 | + comment => 'testcomment', |
| 17 | + user => 'test-user', |
| 18 | + password => 'test1', |
| 19 | + tablespace => 'postgresql-test-db', |
| 20 | + } |
| 21 | + MANIFEST |
23 | 22 |
|
24 |
| - idempotent_apply(pp) |
| 23 | + idempotent_apply(pp) |
25 | 24 |
|
26 |
| - # Verify that the postgres password works |
27 |
| - run_shell("echo 'localhost:*:*:postgres:\'space password\'' > /root/.pgpass") |
28 |
| - run_shell('chmod 600 /root/.pgpass') |
29 |
| - run_shell("psql -U postgres -h localhost --command='\\l'") |
| 25 | + # Verify that the postgres password works |
| 26 | + run_shell("echo 'localhost:*:*:postgres:\'space password\'' > /root/.pgpass") |
| 27 | + run_shell('chmod 600 /root/.pgpass') |
| 28 | + run_shell("psql -U postgres -h localhost --command='\\l'") |
30 | 29 |
|
31 |
| - result = psql('--command="select datname from pg_database" "postgresql-test-db"') |
32 |
| - expect(result.stdout).to match(%r{postgresql-test-db}) |
33 |
| - expect(result.stderr).to eq('') |
| 30 | + result = psql('--command="select datname from pg_database" "postgresql-test-db"') |
| 31 | + expect(result.stdout).to match(%r{postgresql-test-db}) |
| 32 | + expect(result.stderr).to eq('') |
34 | 33 |
|
35 |
| - result = psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"') |
36 |
| - expect(result.stdout).to match(%r{\(1 row\)}) |
37 |
| - comment_information_function = if Gem::Version.new(postgresql_version) > Gem::Version.new('8.1') |
38 |
| - 'shobj_description' |
39 |
| - else |
40 |
| - 'obj_description' |
41 |
| - end |
42 |
| - result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength |
43 |
| - expect(result.stdout).to match(%r{\(1 row\)}) |
44 |
| - ensure |
45 |
| - psql('--command=\'drop database "postgresql-test-db"\'') |
46 |
| - end |
| 34 | + result = psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"') |
| 35 | + expect(result.stdout).to match(%r{\(1 row\)}) |
| 36 | + comment_information_function = if Gem::Version.new(postgresql_version) > Gem::Version.new('8.1') |
| 37 | + 'shobj_description' |
| 38 | + else |
| 39 | + 'obj_description' |
| 40 | + end |
| 41 | + result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength |
| 42 | + expect(result.stdout).to match(%r{\(1 row\)}) |
| 43 | + ensure |
| 44 | + psql('--command=\'drop database "postgresql-test-db"\'') |
47 | 45 | end
|
48 | 46 | end
|
0 commit comments