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