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