|
6 | 6 |
|
7 | 7 | use PostgreSQL::Test::Cluster;
|
8 | 8 | use PostgreSQL::Test::Utils;
|
9 |
| -use Test::More tests => 22; |
| 9 | +use Test::More tests => 25; |
10 | 10 |
|
11 | 11 | program_help_ok('createdb');
|
12 | 12 | program_version_ok('createdb');
|
|
28 | 28 | $node->command_fails([ 'createdb', 'foobar1' ],
|
29 | 29 | 'fails if database already exists');
|
30 | 30 |
|
| 31 | +# Check use of templates with shared dependencies copied from the template. |
| 32 | +my ($ret, $stdout, $stderr) = $node->psql( |
| 33 | + 'foobar2', |
| 34 | + 'CREATE ROLE role_foobar; |
| 35 | +CREATE TABLE tab_foobar (id int); |
| 36 | +ALTER TABLE tab_foobar owner to role_foobar; |
| 37 | +CREATE POLICY pol_foobar ON tab_foobar FOR ALL TO role_foobar;'); |
| 38 | +$node->issues_sql_like( |
| 39 | + [ 'createdb', '-l', 'C', '-T', 'foobar2', 'foobar3' ], |
| 40 | + qr/statement: CREATE DATABASE foobar3 TEMPLATE foobar2/, |
| 41 | + 'create database with template'); |
| 42 | +($ret, $stdout, $stderr) = $node->psql( |
| 43 | + 'foobar3', |
| 44 | + "SELECT pg_describe_object(classid, objid, objsubid) AS obj, |
| 45 | + pg_describe_object(refclassid, refobjid, 0) AS refobj |
| 46 | + FROM pg_shdepend s JOIN pg_database d ON (d.oid = s.dbid) |
| 47 | + WHERE d.datname = 'foobar3' ORDER BY obj;", on_error_die => 1); |
| 48 | +chomp($stdout); |
| 49 | +like( |
| 50 | + $stdout, |
| 51 | + qr/^policy pol_foobar on table tab_foobar\|role role_foobar |
| 52 | +table tab_foobar\|role role_foobar$/, |
| 53 | + 'shared dependencies copied over to target database'); |
| 54 | + |
31 | 55 | # Check quote handling with incorrect option values.
|
32 | 56 | $node->command_checks_all(
|
33 | 57 | [ 'createdb', '--encoding', "foo'; SELECT '1", 'foobar2' ],
|
|
0 commit comments