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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
use warnings;
use strict;
use File::Temp;
use Test::More;
use PGObject::Util::DBAdmin;
use Test::Exception;
plan skip_all => 'DB_TESTING not set' unless $ENV{DB_TESTING};
plan tests => 8;
my $output_file = File::Temp->new->filename;
my $db = PGObject::Util::DBAdmin->new(
username => 'postgres' ,
host => 'localhost' ,
port => '5432' ,
dbname => 'pgobject_test_db',
);
dies_ok {
$db->backup(
tempdir => 'This_directory_does_not_exist'
)
} 'backup db with non-existent tempdir';
dies_ok {
$db->backup(
format => 'THIS_IS_A_BAD_FORMAT',
file => $output_file,
)
} 'backup db with bad format';
dies_ok {
$db->backup(
file => 't/data/an_existing_file/cannot_write'
)
} 'backup db cannot write to specified file';
dies_ok {
$db->backup(
tempdir => 't/data/an_existing_file'
)
} 'backup db tempdir is an existing file';
dies_ok {
$db->backup_globals(
tempdir => 'This_directory_does_not_exist'
)
} 'backup_globals with non-existent tempdir';
dies_ok {
$db->backup_globals(
file => 't/data/an_existing_file/cannot_write'
)
} 'backup_globals cannot write to specified file';
dies_ok {
$db->backup_globals(
tempdir => 't/data/an_existing_file'
)
} 'backup_globals tempdir is an existing file';
dies_ok {
$db->restore(
file => 't/data/an_existing_file',
format => 'AN_INVALID_FORMAT',
)
} 'restore method called with invalid format';
unlink $output_file;
|