Commit | Line | Data |
fa994d3c |
1 | use strict; |
2 | use Test::More; |
3 | use lib qw(t/lib); |
3e3c3fc7 |
4 | use File::Path; |
fa994d3c |
5 | use make_dbictest_db; |
6 | |
3e3c3fc7 |
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 | |
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 | |
3e3c3fc7 |
28 | plan tests => 4; |
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 | eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; |
37 | like($@, qr|DBICTest/Schema/1.pm exists, will not overwrite|, |
38 | 'death when attempting to overwrite without option'); |
39 | |
40 | rmtree($dump_path, 1, 0711); |
41 | |
42 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
43 | ok(!$@, 'no death with dump_directory set (overwrite1)') or diag "Dump failed: $@"; |
44 | |
45 | DBICTest::Schema::2->loader(undef); |
46 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
47 | ok(!$@, 'no death with dump_directory set (overwrite2)') or diag "Dump failed: $@"; |
fa994d3c |
48 | |
3e3c3fc7 |
49 | END { rmtree($dump_path, 1, 0711); } |