11 use File::Temp qw/ tempdir tempfile /;
13 use DBIx::Class::Schema::Loader;
14 use DBIx::Class::Schema::Loader::Utils qw/ slurp_file /;
16 my $tempdir = tempdir( CLEANUP => 1 );
17 my $foopm = File::Spec->catfile( $tempdir,
18 qw| DBICTest Schema Overwrite_modifications Result Foo.pm |);
21 # check that we dumped
22 ok( -f $foopm, 'looks like it dumped' );
24 # now modify one of the files
26 open my $in, '<', $foopm or die "$! reading $foopm";
27 my ($tfh,$temp) = tempfile( UNLINK => 1);
29 s/"bars"/"somethingelse"/;
33 copy( $temp, $foopm );
36 # and dump again without overwrites
39 } qr/mismatch/, 'throws error dumping without overwrite_modifications';
41 # and then dump with overwrite
43 dump_schema( overwrite_modifications => 1 );
44 } 'does not throw when dumping with overwrite_modifications';
47 unlike slurp_file $foopm, qr/"somethingelse"/, "Modifications actually overwritten";
51 # need to poke _loader_invoked in order to be able to rerun the
52 # loader multiple times.
53 DBICTest::Schema::Overwrite_modifications->_loader_invoked(0)
54 if @DBICTest::Schema::Overwrite_modifications::ISA;
59 DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::Overwrite_modifications',
60 { dump_directory => $tempdir, @$args },
61 [ $make_dbictest_db::dsn ],
63 } [qr/^Dumping manual schema/, qr/^Schema dump completed/ ];