X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F40overwrite_modifications.t;h=05130f954fb5f0e2764289b73a3d57279308d5f9;hb=48c1a6c5fea9f320f94d583f79936b43c6d38710;hp=13154ddf7e86f75458d16b73c6bace2906e10367;hpb=f22644d75f6f7bc63bc695c32ad6dd59e7af359b;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/40overwrite_modifications.t b/t/40overwrite_modifications.t index 13154dd..05130f9 100644 --- a/t/40overwrite_modifications.t +++ b/t/40overwrite_modifications.t @@ -1,6 +1,7 @@ use strict; -use Test::More tests => 3; +use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use make_dbictest_db; @@ -9,6 +10,7 @@ use File::Spec; use File::Temp qw/ tempdir tempfile /; use DBIx::Class::Schema::Loader; +use DBIx::Class::Schema::Loader::Utils qw/ slurp_file /; my $tempdir = tempdir( CLEANUP => 1 ); my $foopm = File::Spec->catfile( $tempdir, @@ -23,8 +25,8 @@ ok( -f $foopm, 'looks like it dumped' ); open my $in, '<', $foopm or die "$! reading $foopm"; my ($tfh,$temp) = tempfile( UNLINK => 1); while(<$in>) { - s/"bars"/"somethingelse"/; - print $tfh $_; + s/"bars"/"somethingelse"/; + print $tfh $_; } close $tfh; copy( $temp, $foopm ); @@ -40,21 +42,24 @@ lives_ok { dump_schema( overwrite_modifications => 1 ); } 'does not throw when dumping with overwrite_modifications'; + +unlike slurp_file $foopm, qr/"somethingelse"/, "Modifications actually overwritten"; + sub dump_schema { # need to poke _loader_invoked in order to be able to rerun the # loader multiple times. DBICTest::Schema::Overwrite_modifications->_loader_invoked(0) - if @DBICTest::Schema::Overwrite_modifications::ISA; - - local $SIG{__WARN__} = sub { - warn @_ - unless $_[0] =~ /^Dumping manual schema|^Schema dump completed/; - }; - DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::Overwrite_modifications', - { dump_directory => $tempdir, - @_, - }, - [ $make_dbictest_db::dsn ], - ); + if @DBICTest::Schema::Overwrite_modifications::ISA; + + my $args = \@_; + + warnings_exist { + DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::Overwrite_modifications', + { dump_directory => $tempdir, @$args }, + [ $make_dbictest_db::dsn ], + ); + } [qr/^Dumping manual schema/, qr/^Schema dump completed/ ]; } + +done_testing();