Commit | Line | Data |
fa994d3c |
1 | use strict; |
2 | use Test::More; |
02356864 |
3 | use Test::Warn; |
fa994d3c |
4 | use lib qw(t/lib); |
3e3c3fc7 |
5 | use File::Path; |
fa994d3c |
6 | use make_dbictest_db; |
7 | |
3e3c3fc7 |
8 | my $dump_path = './t/_dump'; |
9 | |
10 | { |
11 | package DBICTest::Schema::1; |
12 | use base qw/ DBIx::Class::Schema::Loader /; |
13 | __PACKAGE__->loader_options( |
14 | relationships => 1, |
15 | dump_directory => $dump_path, |
16 | ); |
17 | } |
18 | |
fa994d3c |
19 | { |
3e3c3fc7 |
20 | package DBICTest::Schema::2; |
fa994d3c |
21 | use base qw/ DBIx::Class::Schema::Loader /; |
22 | __PACKAGE__->loader_options( |
23 | relationships => 1, |
3e3c3fc7 |
24 | dump_directory => $dump_path, |
fa994d3c |
25 | dump_overwrite => 1, |
26 | ); |
fa994d3c |
27 | } |
28 | |
3e3c3fc7 |
29 | plan tests => 4; |
30 | |
31 | rmtree($dump_path, 1, 0711); |
32 | |
33 | eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; |
34 | ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@"; |
35 | |
36 | DBICTest::Schema::1->loader(undef); |
02356864 |
37 | warnings_like { DBICTest::Schema::1->connect($make_dbictest_db::dsn) } |
38 | [ |
39 | qr|Dumping manual schema|, |
40 | (qr|DBICTest/Schema/1.*?.pm exists, will not overwrite|) x 3, |
41 | qr|Schema dump completed| |
42 | ], |
43 | 'warn and skip when attempting to overwrite without option'; |
3e3c3fc7 |
44 | |
45 | rmtree($dump_path, 1, 0711); |
46 | |
47 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
02356864 |
48 | ok(!$@, 'no death with dump_directory set (overwrite1)') |
49 | or diag "Dump failed: $@"; |
3e3c3fc7 |
50 | |
51 | DBICTest::Schema::2->loader(undef); |
52 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
02356864 |
53 | ok(!$@, 'no death with dump_directory set (overwrite2)') |
54 | or diag "Dump failed: $@"; |
fa994d3c |
55 | |
02356864 |
56 | END { rmtree($dump_path, 1, 1); } |