test_pg_dump TAP test whitespace cleanup

The formatting of the perl hashes used in the TAP tests for test_pg_dump
was rather horribly inconsistent and made it more difficult than it
really should have been to add new tests or adjust what tests are for
what runs, etc.

Reformat to clean that all up.

Whitespace-only changes.
This commit is contained in:
Stephen Frost 2017-01-29 23:05:07 -05:00
parent 4bf371cf2a
commit fb94ca77f1
1 changed files with 462 additions and 322 deletions

View File

@ -61,94 +61,142 @@ my %pgdump_runs = (
'-c',
'--if-exists',
'-E', 'UTF8', # no-op, just tests that option is accepted
'postgres', ], },
'postgres',
], },
column_inserts => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/column_inserts.sql", '-a',
'--column-inserts', 'postgres', ], },
'pg_dump',
'-f', "$tempdir/column_inserts.sql",
'-a',
'--column-inserts',
'postgres',
], },
createdb => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/createdb.sql",
'-C',
'-R', # no-op, just for testing
'postgres', ], },
'postgres',
], },
data_only => {
dump_cmd => [
'pg_dump',
'-f', "$tempdir/data_only.sql",
'-a',
'-v', # no-op, just make sure it works
'postgres', ], },
'postgres',
], },
defaults => {
dump_cmd => [ 'pg_dump', '-f', "$tempdir/defaults.sql", 'postgres', ],
},
dump_cmd => [
'pg_dump',
'-f', "$tempdir/defaults.sql",
'postgres',
], },
defaults_custom_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fc', '-Z6', '-f',
"$tempdir/defaults_custom_format.dump", 'postgres', ],
'pg_dump',
'-Fc',
'-Z6',
'-f', "$tempdir/defaults_custom_format.dump",
'postgres',
],
restore_cmd => [
'pg_restore',
'-f',
"$tempdir/defaults_custom_format.sql",
"$tempdir/defaults_custom_format.dump", ], },
'-f', "$tempdir/defaults_custom_format.sql",
"$tempdir/defaults_custom_format.dump",
], },
defaults_dir_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fd', '-f', "$tempdir/defaults_dir_format",
'postgres', ],
'pg_dump',
'-Fd',
'-f', "$tempdir/defaults_dir_format",
'postgres',
],
restore_cmd => [
'pg_restore',
'-f',
"$tempdir/defaults_dir_format.sql",
"$tempdir/defaults_dir_format", ], },
'-f', "$tempdir/defaults_dir_format.sql",
"$tempdir/defaults_dir_format",
], },
defaults_parallel => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Fd', '-j2', '-f', "$tempdir/defaults_parallel",
'postgres', ],
'pg_dump',
'-Fd',
'-j2',
'-f', "$tempdir/defaults_parallel",
'postgres',
],
restore_cmd => [
'pg_restore', '-f',
"$tempdir/defaults_parallel.sql", "$tempdir/defaults_parallel", ],
'pg_restore',
'-f', "$tempdir/defaults_parallel.sql",
"$tempdir/defaults_parallel",
],
},
defaults_tar_format => {
test_key => 'defaults',
dump_cmd => [
'pg_dump', '-Ft', '-f', "$tempdir/defaults_tar_format.tar",
'postgres', ],
'pg_dump',
'-Ft',
'-f', "$tempdir/defaults_tar_format.tar",
'postgres',
],
restore_cmd => [
'pg_restore',
'-f',
"$tempdir/defaults_tar_format.sql",
"$tempdir/defaults_tar_format.tar", ], },
'-f', "$tempdir/defaults_tar_format.sql",
"$tempdir/defaults_tar_format.tar",
], },
pg_dumpall_globals => {
dump_cmd =>
[ 'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
dump_cmd => [
'pg_dumpall',
'-f', "$tempdir/pg_dumpall_globals.sql",
'-g',
], },
no_privs => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/no_privs.sql", '-x', 'postgres', ], },
dump_cmd => [
'pg_dump',
'-f', "$tempdir/no_privs.sql",
'-x',
'postgres',
], },
no_owner => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/no_owner.sql", '-O', 'postgres', ], },
dump_cmd => [
'pg_dump',
'-f', "$tempdir/no_owner.sql",
'-O',
'postgres',
], },
schema_only => {
dump_cmd =>
[ 'pg_dump', '-f', "$tempdir/schema_only.sql", '-s', 'postgres', ],
},
dump_cmd => [
'pg_dump',
'-f', "$tempdir/schema_only.sql",
'-s',
'postgres',
], },
section_pre_data => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/section_pre_data.sql",
'--section=pre-data', 'postgres', ], },
'pg_dump',
'-f', "$tempdir/section_pre_data.sql",
'--section=pre-data',
'postgres',
], },
section_data => {
dump_cmd => [
'pg_dump', '-f',
"$tempdir/section_data.sql", '--section=data',
'postgres', ], },
'pg_dump',
'-f', "$tempdir/section_data.sql",
'--section=data',
'postgres',
], },
section_post_data => {
dump_cmd => [
'pg_dump', '-f', "$tempdir/section_post_data.sql",
'--section=post-data', 'postgres', ], },);
'pg_dump',
'-f', "$tempdir/section_post_data.sql",
'--section=post-data',
'postgres',
], },
);
###############################################################
# Definition of the tests to run.
@ -202,16 +250,21 @@ my %tests = (
no_privs => 1,
no_owner => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
binary_upgrade => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE ROLE regress_dump_test_role' => {
create_order => 1,
create_sql => 'CREATE ROLE regress_dump_test_role;',
regexp => qr/^CREATE ROLE regress_dump_test_role;\n/m,
like => { pg_dumpall_globals => 1, },
like => {
pg_dumpall_globals => 1,
},
unlike => {
binary_upgrade => 1,
clean => 1,
@ -222,7 +275,9 @@ my %tests = (
no_owner => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE SEQUENCE regress_pg_dump_table_col1_seq' => {
regexp => qr/^
\QCREATE SEQUENCE regress_pg_dump_table_col1_seq\E
@ -232,7 +287,9 @@ my %tests = (
\n\s+\QNO MAXVALUE\E
\n\s+\QCACHE 1;\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -243,7 +300,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE SEQUENCE regress_pg_dump_seq' => {
regexp => qr/^
\QCREATE SEQUENCE regress_pg_dump_seq\E
@ -253,7 +312,9 @@ my %tests = (
\n\s+\QNO MAXVALUE\E
\n\s+\QCACHE 1;\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -264,7 +325,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'SETVAL SEQUENCE regress_seq_dumpable' => {
create_order => 6,
create_sql => qq{SELECT nextval('regress_seq_dumpable');},
@ -278,19 +341,24 @@ my %tests = (
data_only => 1,
defaults => 1,
no_owner => 1,
no_privs => 1, },
no_privs => 1,
},
unlike => {
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE TABLE regress_pg_dump_table' => {
regexp => qr/^
\QCREATE TABLE regress_pg_dump_table (\E
\n\s+\Qcol1 integer NOT NULL,\E
\n\s+\Qcol2 integer\E
\n\);\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -301,12 +369,16 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE ACCESS METHOD regress_test_am' => {
regexp => qr/^
\QCREATE ACCESS METHOD regress_test_am TYPE INDEX HANDLER bthandler;\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -317,7 +389,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'COMMENT ON EXTENSION test_pg_dump' => {
regexp => qr/^
\QCOMMENT ON EXTENSION test_pg_dump \E
@ -332,17 +406,22 @@ my %tests = (
no_privs => 1,
no_owner => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
pg_dumpall_globals => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT SELECT ON TABLE regress_pg_dump_table' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT SELECT ON TABLE regress_pg_dump_table TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -353,14 +432,18 @@ my %tests = (
section_pre_data => 1,
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT SELECT(col1) ON regress_pg_dump_table' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT SELECT(col1) ON TABLE regress_pg_dump_table TO PUBLIC;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -371,9 +454,11 @@ my %tests = (
section_pre_data => 1,
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role' =>
{ create_order => 4,
section_post_data => 1,
}, },
'GRANT SELECT(col2) ON regress_pg_dump_table TO regress_dump_test_role' => {
create_order => 4,
create_sql => 'GRANT SELECT(col2) ON regress_pg_dump_table
TO regress_dump_test_role;',
regexp => qr/^
@ -387,13 +472,15 @@ my %tests = (
defaults => 1,
no_owner => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role'
=> {
section_post_data => 1,
}, },
'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' => {
create_order => 5,
create_sql => 'GRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq
TO regress_dump_test_role;',
@ -408,16 +495,21 @@ my %tests = (
defaults => 1,
no_owner => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => {
regexp => qr/^
\QGRANT USAGE ON SEQUENCE regress_pg_dump_seq TO regress_dump_test_role;\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -428,7 +520,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'REVOKE SELECT(col1) ON regress_pg_dump_table' => {
create_order => 3,
create_sql => 'REVOKE SELECT(col1) ON regress_pg_dump_table
@ -444,11 +538,14 @@ my %tests = (
defaults => 1,
no_owner => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
no_privs => 1,
pg_dumpall_globals => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
# Objects included in extension part of a schema created by this extension */
'CREATE TABLE regress_pg_dump_schema.test_table' => {
regexp => qr/^
@ -456,7 +553,9 @@ my %tests = (
\n\s+\Qcol1 integer,\E
\n\s+\Qcol2 integer\E
\n\);\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -467,14 +566,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT SELECT ON regress_pg_dump_schema.test_table' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT SELECT ON TABLE test_table TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -485,7 +588,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE SEQUENCE regress_pg_dump_schema.test_seq' => {
regexp => qr/^
\QCREATE SEQUENCE test_seq\E
@ -495,7 +600,9 @@ my %tests = (
\n\s+\QNO MAXVALUE\E
\n\s+\QCACHE 1;\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -506,14 +613,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT USAGE ON regress_pg_dump_schema.test_seq' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT USAGE ON SEQUENCE test_seq TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -524,13 +635,17 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE TYPE regress_pg_dump_schema.test_type' => {
regexp => qr/^
\QCREATE TYPE test_type AS (\E
\n\s+\Qcol1 integer\E
\n\);\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -541,14 +656,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT USAGE ON regress_pg_dump_schema.test_type' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT ALL ON TYPE test_type TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -559,13 +678,17 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE FUNCTION regress_pg_dump_schema.test_func' => {
regexp => qr/^
\QCREATE FUNCTION test_func() RETURNS integer\E
\n\s+\QLANGUAGE sql\E
\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -576,14 +699,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT ALL ON regress_pg_dump_schema.test_func' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT ALL ON FUNCTION test_func() TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -594,14 +721,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'CREATE AGGREGATE regress_pg_dump_schema.test_agg' => {
regexp => qr/^
\QCREATE AGGREGATE test_agg(smallint) (\E
\n\s+\QSFUNC = int2_sum,\E
\n\s+\QSTYPE = bigint\E
\n\);\n/xm,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -612,14 +743,18 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
'GRANT ALL ON regress_pg_dump_schema.test_agg' => {
regexp => qr/^
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(true);\E\n
\QGRANT ALL ON FUNCTION test_agg(smallint) TO regress_dump_test_role;\E\n
\QSELECT pg_catalog.binary_upgrade_set_record_init_privs(false);\E
\n/xms,
like => { binary_upgrade => 1, },
like => {
binary_upgrade => 1,
},
unlike => {
clean => 1,
clean_if_exists => 1,
@ -630,7 +765,9 @@ my %tests = (
pg_dumpall_globals => 1,
schema_only => 1,
section_pre_data => 1,
section_post_data => 1, }, },
section_post_data => 1,
}, },
# Objects not included in extension, part of schema created by extension
'CREATE TABLE regress_pg_dump_schema.external_tab' => {
create_order => 4,
@ -649,10 +786,13 @@ my %tests = (
no_owner => 1,
no_privs => 1,
schema_only => 1,
section_pre_data => 1, },
section_pre_data => 1,
},
unlike => {
pg_dumpall_globals => 1,
section_post_data => 1, }, }, );
section_post_data => 1,
}, },
);
#########################################
# Create a PG instance to test actually dumping from