fix table count test in common tests, inc version for dev release, add extra tests...
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 22dump.t
CommitLineData
fa994d3c 1use strict;
2use Test::More;
3use lib qw(t/lib);
3e3c3fc7 4use File::Path;
fa994d3c 5use make_dbictest_db;
6
3e3c3fc7 7my $dump_path = './t/_dump';
8
fdd8ff16 9local $SIG{__WARN__} = sub {
10 warn $_[0] unless $_[0] =~
11 /really_erase_my_files|Dumping manual schema|Schema dump completed/;
12};
13
3e3c3fc7 14{
15 package DBICTest::Schema::1;
16 use base qw/ DBIx::Class::Schema::Loader /;
17 __PACKAGE__->loader_options(
3e3c3fc7 18 dump_directory => $dump_path,
19 );
20}
21
fa994d3c 22{
3e3c3fc7 23 package DBICTest::Schema::2;
fa994d3c 24 use base qw/ DBIx::Class::Schema::Loader /;
25 __PACKAGE__->loader_options(
3e3c3fc7 26 dump_directory => $dump_path,
28b4691d 27 really_erase_my_files => 1,
fa994d3c 28 );
fa994d3c 29}
30
7cab3ab7 31plan tests => 5;
3e3c3fc7 32
520107ef 33rmtree($dump_path, 1, 1);
3e3c3fc7 34
35eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
36ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
37
59cfa251 38DBICTest::Schema::1->_loader_invoked(undef);
9395f33a 39
e682950b 40SKIP: {
2ffd6b4c 41 my @warnings_regexes = (
42 qr|Dumping manual schema|,
43 qr|Schema dump completed|,
44 );
45
46 skip "ActiveState perl produces additional warnings", scalar @warnings_regexes
e682950b 47 if ($^O eq 'MSWin32');
9395f33a 48
e682950b 49 my @warn_output;
50 {
51 local $SIG{__WARN__} = sub { push(@warn_output, @_) };
52 DBICTest::Schema::1->connect($make_dbictest_db::dsn);
53 }
3e3c3fc7 54
e682950b 55 like(shift @warn_output, $_) foreach (@warnings_regexes);
56
57 rmtree($dump_path, 1, 1);
58}
3e3c3fc7 59
60eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
02356864 61ok(!$@, 'no death with dump_directory set (overwrite1)')
62 or diag "Dump failed: $@";
3e3c3fc7 63
59cfa251 64DBICTest::Schema::2->_loader_invoked(undef);
3e3c3fc7 65eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
02356864 66ok(!$@, 'no death with dump_directory set (overwrite2)')
67 or diag "Dump failed: $@";
fa994d3c 68
7e9ee6a4 69END { rmtree($dump_path, 1, 1); }