X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F22dump.t;h=cc92d9d9168f47796635b714cfee697a473a204c;hb=07ba0049cf3d965bae811cc21ea28abbad58bf3c;hp=5f6ff6a0fe07d9cc2e3517fbe3481f84ca05e454;hpb=fa994d3c6ada53f4610e6384fe924d4bf8163a68;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/22dump.t b/t/22dump.t index 5f6ff6a..cc92d9d 100644 --- a/t/22dump.t +++ b/t/22dump.t @@ -1,21 +1,69 @@ use strict; use Test::More; +use Test::Exception; +use Test::Warn; use lib qw(t/lib); +use File::Path; use make_dbictest_db; +use dbixcsl_test_dir qw/$tdir/; + +my $dump_path = "$tdir/dump"; + { - package DBICTest::Schema; + package DBICTest::Schema::1; use base qw/ DBIx::Class::Schema::Loader /; __PACKAGE__->loader_options( - relationships => 1, - dump_directory => './t/_dump', - dump_overwrite => 1, + dump_directory => $dump_path, ); - } -plan tests => 1; +{ + package DBICTest::Schema::2; + use base qw/ DBIx::Class::Schema::Loader /; + __PACKAGE__->loader_options( + dump_directory => $dump_path, + really_erase_my_files => 1, + ); +} + +plan tests => 7; + +rmtree($dump_path, 1, 1); + +lives_ok { + warnings_exist { DBICTest::Schema::1->connect($make_dbictest_db::dsn) } + [ qr|^Dumping manual schema|, qr|^Schema dump completed| ]; +} 'no death with dump_directory set' or diag "Dump failed: $@"; + +DBICTest::Schema::1->_loader_invoked(undef); + +SKIP: { + skip "ActiveState perl produces additional warnings", 1 + if ($^O eq 'MSWin32'); + + warnings_exist { DBICTest::Schema::1->connect($make_dbictest_db::dsn) } + [ qr|^Dumping manual schema|, qr|^Schema dump completed| ]; + + rmtree($dump_path, 1, 1); +} + +lives_ok { + warnings_exist { DBICTest::Schema::2->connect($make_dbictest_db::dsn) } + [ qr|^Dumping manual schema|, qr|^Schema dump completed| ]; +} 'no death with dump_directory set (overwrite1)' or diag "Dump failed: $@"; + +DBICTest::Schema::2->_loader_invoked(undef); + +lives_ok { + warnings_exist { DBICTest::Schema::2->connect($make_dbictest_db::dsn) } + [ + qr/^Dumping manual schema/, + qr|^Deleting .+Schema/2.+ due to 'really_erase_my_files'|, + qr|^Deleting .+Schema/2/Result/Foo.+ due to 'really_erase_my_files'|, + qr|^Deleting .+Schema/2/Result/Bar.+ due to 'really_erase_my_files'|, + qr/^Schema dump completed/ + ]; +} 'no death with dump_directory set (overwrite2)' or diag "Dump failed: $@"; -eval { DBICTest::Schema->connect($make_dbictest_db::dsn) }; -ok(!$@, 'no death with dump_directory set') - or diag "Dump failed: $@"; +END { rmtree($dump_path, 1, 1); }