Merge 'current' into 'back-compat'
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / backcompat / 0.04006 / 22dump.t
CommitLineData
9a95164d 1use strict;
2use Test::More;
1c94fb11 3use lib qw(t/backcompat/0.04006/lib);
9a95164d 4use File::Path;
5use make_dbictest_db;
1c94fb11 6use Test::More;
fb3bb595 7plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests'
1c94fb11 8 unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT};
9
9a95164d 10
11my $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
30plan tests => 5;
31
32rmtree($dump_path, 1, 1);
33
34eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
35ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
36
37DBICTest::Schema::1->_loader_invoked(undef);
38
39SKIP: {
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
59eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
60ok(!$@, 'no death with dump_directory set (overwrite1)')
61 or diag "Dump failed: $@";
62
63DBICTest::Schema::2->_loader_invoked(undef);
64eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
65ok(!$@, 'no death with dump_directory set (overwrite2)')
66 or diag "Dump failed: $@";
67
68END { rmtree($dump_path, 1, 1); }