d41fb6685d511232b3057086fe8533f1c43d79fc
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 23dumpmore.t
1 use strict;
2 use Test::More;
3 use lib qw(t/lib);
4 use File::Path;
5 use make_dbictest_db;
6 require DBIx::Class::Schema::Loader;
7
8 plan tests => 5;
9
10 plan skip_all => "ActiveState perl produces additional warnings"
11     if ($^O eq 'MSWin32');
12
13 my $dump_path = './t/_dump';
14
15 sub do_dump_test {
16     my ($schema_class, $opts) = @_;
17
18     rmtree($dump_path, 1, 1);
19
20     no strict 'refs';
21     @{$schema_class . '::ISA'} = ('DBIx::Class::Schema::Loader');
22     $schema_class->loader_options(dump_directory => $dump_path, %$opts);
23
24     my @warn_output;
25     eval {
26         local $SIG{__WARN__} = sub { push(@warn_output, @_) };
27         $schema_class->connect($make_dbictest_db::dsn);
28     };
29     my $err = $@;
30     $schema_class->storage->disconnect if !$err && $schema_class->storage;
31     undef *{$schema_class};
32     return ($err, \@warn_output);
33 }
34
35
36 {
37     my ($err, $warn) = do_dump_test('DBICTest::Schema::1', { });
38     ok(!$err);
39     is(@$warn, 2);
40     like($warn->[0], qr/Dumping manual schema for DBICTest::Schema::1 to directory /);
41     like($warn->[1], qr/Schema dump completed/);
42 }
43
44 ok(1);
45
46 # XXX obviously this test file needs to be fleshed out more :)
47
48 # END { rmtree($dump_path, 1, 1); }