File: 22dump.t

package info (click to toggle)
libdbix-class-schema-loader-perl 0.07053-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,464 kB
  • sloc: perl: 11,520; sh: 544; makefile: 4
file content (74 lines) | stat: -rw-r--r-- 1,920 bytes parent folder | download | duplicates (4)
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
67
68
69
70
71
72
73
74
use DBIx::Class::Schema::Loader::Optional::Dependencies
    -skip_all_without => 'test_backcompat';

use strict;
use warnings;
use Test::More;
use lib qw(t/backcompat/0.04006/lib);
use File::Path;
use make_dbictest_db;
use dbixcsl_test_dir qw/$tdir/;

my $dump_path = "$tdir/dump";

local $SIG{__WARN__} = sub {
    warn @_ unless $_[0] =~
        /^Dumping manual schema|really_erase_my_files|^Schema dump complete/;
};

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

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

plan tests => 5;

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_invoked(undef);

SKIP: {
    my @warnings_regexes = (
        qr|Dumping manual schema|,
        qr|Schema dump completed|,
    );

    skip "ActiveState perl produces additional warnings", scalar @warnings_regexes
        if ($^O eq 'MSWin32');

    my @warn_output;
    {
        local $SIG{__WARN__} = sub { push(@warn_output, @_) };
        DBICTest::Schema::1->connect($make_dbictest_db::dsn);
    }

    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_invoked(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) if $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; }