0394101e4a0fc4df7d0fb179c4875c0b6d36d7e5
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / backcompat / 0.04006 / 22dump.t
1 use strict;
2 use Test::More;
3 use lib qw(t/backcompat/0.04006/lib);
4 use File::Path;
5 use make_dbictest_db;
6 use Test::More;
7 plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests'
8     unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT};
9
10
11 my $dump_path = './t/_dump';
12
13 {
14     package DBICTest::Schema::1;
15     use base qw/ DBIx::Class::Schema::Loader /;
16     __PACKAGE__->loader_options(
17         dump_directory => $dump_path,
18     );
19 }
20
21 {
22     package DBICTest::Schema::2;
23     use base qw/ DBIx::Class::Schema::Loader /;
24     __PACKAGE__->loader_options(
25         dump_directory => $dump_path,
26         really_erase_my_files => 1,
27     );
28 }
29
30 plan tests => 5;
31
32 rmtree($dump_path, 1, 1);
33
34 eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
35 ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
36
37 DBICTest::Schema::1->_loader_invoked(undef);
38
39 SKIP: {
40   my @warnings_regexes = (
41       qr|Dumping manual schema|,
42       qr|Schema dump completed|,
43   );
44
45   skip "ActiveState perl produces additional warnings", scalar @warnings_regexes
46     if ($^O eq 'MSWin32');
47
48   my @warn_output;
49   {
50       local $SIG{__WARN__} = sub { push(@warn_output, @_) };
51       DBICTest::Schema::1->connect($make_dbictest_db::dsn);
52   }
53
54   like(shift @warn_output, $_) foreach (@warnings_regexes);
55
56   rmtree($dump_path, 1, 1);
57 }
58
59 eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
60 ok(!$@, 'no death with dump_directory set (overwrite1)')
61     or diag "Dump failed: $@";
62
63 DBICTest::Schema::2->_loader_invoked(undef);
64 eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
65 ok(!$@, 'no death with dump_directory set (overwrite2)')
66     or diag "Dump failed: $@";
67
68 END { rmtree($dump_path, 1, 1); }