removed Test::Warn
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 22dump.t
1 use strict;
2 use Test::More;
3 use lib qw(t/lib);
4 use File::Path;
5 use make_dbictest_db;
6
7 my $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
18 {
19     package DBICTest::Schema::2;
20     use base qw/ DBIx::Class::Schema::Loader /;
21     __PACKAGE__->loader_options(
22         relationships => 1,
23         dump_directory => $dump_path,
24         dump_overwrite => 1,
25     );
26 }
27
28 plan tests => 8;
29
30 rmtree($dump_path, 1, 0711);
31
32 eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
33 ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
34
35 DBICTest::Schema::1->loader(undef);
36
37 my @warn_output;
38 {
39     local $SIG{__WARN__} = sub { push(@warn_output, @_) };
40     DBICTest::Schema::1->connect($make_dbictest_db::dsn);
41 }
42 my @warnings_regexes = (
43     qr|Dumping manual schema|,
44     (qr|DBICTest/Schema/1.*?.pm exists, will not overwrite|) x 3,
45     qr|Schema dump completed|,
46 );
47
48 like(shift @warn_output, $_) foreach (@warnings_regexes);
49
50 rmtree($dump_path, 1, 0711);
51
52 eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
53 ok(!$@, 'no death with dump_directory set (overwrite1)')
54     or diag "Dump failed: $@";
55
56 DBICTest::Schema::2->loader(undef);
57 eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
58 ok(!$@, 'no death with dump_directory set (overwrite2)')
59     or diag "Dump failed: $@";
60
61 END { rmtree($dump_path, 1, 1); }