X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F22dump.t;h=cc92d9d9168f47796635b714cfee697a473a204c;hb=d16c945ba0c9323ed18df3616c4e9ccefe0e95bd;hp=cdb0f5015ddd30e5dde1fc8e6471ae3486d40fbd;hpb=12c918bdefc9be6e6515f433d6199608a1ca4a58;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/22dump.t b/t/22dump.t index cdb0f50..cc92d9d 100644 --- a/t/22dump.t +++ b/t/22dump.t @@ -1,10 +1,14 @@ 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"; -my $dump_path = './t/_dump'; { package DBICTest::Schema::1; @@ -23,41 +27,43 @@ my $dump_path = './t/_dump'; ); } -plan tests => 5; +plan tests => 7; rmtree($dump_path, 1, 1); -eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; -ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@"; +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", 3 + skip "ActiveState perl produces additional warnings", 1 if ($^O eq 'MSWin32'); - my @warn_output; - { - local $SIG{__WARN__} = sub { push(@warn_output, @_) }; - DBICTest::Schema::1->connect($make_dbictest_db::dsn); - } - my @warnings_regexes = ( - qr|Dumping manual schema|, - qr|Schema dump completed|, - ); - - like(shift @warn_output, $_) foreach (@warnings_regexes); + warnings_exist { DBICTest::Schema::1->connect($make_dbictest_db::dsn) } + [ qr|^Dumping manual schema|, qr|^Schema dump completed| ]; rmtree($dump_path, 1, 1); } -eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; -ok(!$@, 'no death with dump_directory set (overwrite1)') - or diag "Dump failed: $@"; +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); -eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; -ok(!$@, 'no death with dump_directory set (overwrite2)') - or diag "Dump failed: $@"; + +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: $@"; END { rmtree($dump_path, 1, 1); }