statistics_info support
[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
9{
10 package DBICTest::Schema::1;
11 use base qw/ DBIx::Class::Schema::Loader /;
12 __PACKAGE__->loader_options(
13 relationships => 1,
14 dump_directory => $dump_path,
15 );
16}
17
fa994d3c 18{
3e3c3fc7 19 package DBICTest::Schema::2;
fa994d3c 20 use base qw/ DBIx::Class::Schema::Loader /;
21 __PACKAGE__->loader_options(
22 relationships => 1,
3e3c3fc7 23 dump_directory => $dump_path,
fa994d3c 24 dump_overwrite => 1,
25 );
fa994d3c 26}
27
9395f33a 28plan tests => 8;
3e3c3fc7 29
520107ef 30rmtree($dump_path, 1, 1);
3e3c3fc7 31
32eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
33ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
34
59cfa251 35DBICTest::Schema::1->_loader_invoked(undef);
9395f33a 36
e682950b 37SKIP: {
38 skip "ActiveState perl produces additional warnings", 5
39 if ($^O eq 'MSWin32');
9395f33a 40
e682950b 41 my @warn_output;
42 {
43 local $SIG{__WARN__} = sub { push(@warn_output, @_) };
44 DBICTest::Schema::1->connect($make_dbictest_db::dsn);
45 }
46 my @warnings_regexes = (
47 qr|Dumping manual schema|,
48 (qr|DBICTest/Schema/1.*?.pm exists, will not overwrite|) x 3,
49 qr|Schema dump completed|,
50 );
3e3c3fc7 51
e682950b 52 like(shift @warn_output, $_) foreach (@warnings_regexes);
53
54 rmtree($dump_path, 1, 1);
55}
3e3c3fc7 56
57eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
02356864 58ok(!$@, 'no death with dump_directory set (overwrite1)')
59 or diag "Dump failed: $@";
3e3c3fc7 60
59cfa251 61DBICTest::Schema::2->_loader_invoked(undef);
3e3c3fc7 62eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
02356864 63ok(!$@, 'no death with dump_directory set (overwrite2)')
64 or diag "Dump failed: $@";
fa994d3c 65
02356864 66END { rmtree($dump_path, 1, 1); }