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