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