File: 22dump.t

package info (click to toggle)
libdbix-class-schema-loader-perl 0.03009-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 252 kB
  • ctags: 102
  • sloc: perl: 1,636; makefile: 44
file content (66 lines) | stat: -rw-r--r-- 1,621 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use strict;
use Test::More;
use lib qw(t/lib);
use File::Path;
use make_dbictest_db;

my $dump_path = './t/_dump';

{
    package DBICTest::Schema::1;
    use base qw/ DBIx::Class::Schema::Loader /;
    __PACKAGE__->loader_options(
        relationships => 1,
        dump_directory => $dump_path,
    );
}

{
    package DBICTest::Schema::2;
    use base qw/ DBIx::Class::Schema::Loader /;
    __PACKAGE__->loader_options(
        relationships => 1,
        dump_directory => $dump_path,
        dump_overwrite => 1,
    );
}

plan tests => 8;

rmtree($dump_path, 1, 1);

eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";

DBICTest::Schema::1->loader(undef);

SKIP: {
  skip "ActiveState perl produces additional warnings", 5
    if ($^O eq 'MSWin32');

  my @warn_output;
  {
      local $SIG{__WARN__} = sub { push(@warn_output, @_) };
      DBICTest::Schema::1->connect($make_dbictest_db::dsn);
  }
  my @warnings_regexes = (
      qr|Dumping manual schema|,
      (qr|DBICTest/Schema/1.*?.pm exists, will not overwrite|) x 3,
      qr|Schema dump completed|,
  );

  like(shift @warn_output, $_) foreach (@warnings_regexes);

  rmtree($dump_path, 1, 1);
}

eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
ok(!$@, 'no death with dump_directory set (overwrite1)')
    or diag "Dump failed: $@";

DBICTest::Schema::2->loader(undef);
eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
ok(!$@, 'no death with dump_directory set (overwrite2)')
    or diag "Dump failed: $@";

END { rmtree($dump_path, 1, 1); }