handle column accessor collisions with UNIVERSAL methods
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 22dump.t
CommitLineData
fa994d3c 1use strict;
2use Test::More;
c38ec663 3use Test::Exception;
4use Test::Warn;
fa994d3c 5use lib qw(t/lib);
3e3c3fc7 6use File::Path;
fa994d3c 7use make_dbictest_db;
c213fd3d 8use dbixcsl_test_dir qw/$tdir/;
fa994d3c 9
c213fd3d 10my $dump_path = "$tdir/dump";
3e3c3fc7 11
fdd8ff16 12
3e3c3fc7 13{
14 package DBICTest::Schema::1;
15 use base qw/ DBIx::Class::Schema::Loader /;
16 __PACKAGE__->loader_options(
3e3c3fc7 17 dump_directory => $dump_path,
18 );
19}
20
fa994d3c 21{
3e3c3fc7 22 package DBICTest::Schema::2;
fa994d3c 23 use base qw/ DBIx::Class::Schema::Loader /;
24 __PACKAGE__->loader_options(
3e3c3fc7 25 dump_directory => $dump_path,
28b4691d 26 really_erase_my_files => 1,
fa994d3c 27 );
fa994d3c 28}
29
c38ec663 30plan tests => 7;
3e3c3fc7 31
520107ef 32rmtree($dump_path, 1, 1);
3e3c3fc7 33
c38ec663 34lives_ok {
35 warnings_exist { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }
36 [ qr|^Dumping manual schema|, qr|^Schema dump completed| ];
37} 'no death with dump_directory set' or diag "Dump failed: $@";
3e3c3fc7 38
59cfa251 39DBICTest::Schema::1->_loader_invoked(undef);
9395f33a 40
e682950b 41SKIP: {
c38ec663 42 skip "ActiveState perl produces additional warnings", 1
e682950b 43 if ($^O eq 'MSWin32');
9395f33a 44
c38ec663 45 warnings_exist { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }
46 [ qr|^Dumping manual schema|, qr|^Schema dump completed| ];
e682950b 47
48 rmtree($dump_path, 1, 1);
49}
3e3c3fc7 50
c38ec663 51lives_ok {
52 warnings_exist { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }
53 [ qr|^Dumping manual schema|, qr|^Schema dump completed| ];
54} 'no death with dump_directory set (overwrite1)' or diag "Dump failed: $@";
3e3c3fc7 55
59cfa251 56DBICTest::Schema::2->_loader_invoked(undef);
c38ec663 57
58lives_ok {
59 warnings_exist { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }
60 [
61 qr/^Dumping manual schema/,
62 qr|^Deleting .+Schema/2.+ due to 'really_erase_my_files'|,
63 qr|^Deleting .+Schema/2/Result/Foo.+ due to 'really_erase_my_files'|,
64 qr|^Deleting .+Schema/2/Result/Bar.+ due to 'really_erase_my_files'|,
65 qr/^Schema dump completed/
66 ];
67} 'no death with dump_directory set (overwrite2)' or diag "Dump failed: $@";
fa994d3c 68
7e9ee6a4 69END { rmtree($dump_path, 1, 1); }