Attempt to fix 'Attempt to free unreferenced scalar' on 5.8
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 60dbicdump_config.t
1 use DBIx::Class::Schema::Loader::Optional::Dependencies
2     -skip_all_without => 'test_dbicdump_config';
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8 use File::Path qw/make_path rmtree/;
9 use DBIx::Class::Schema::Loader::Utils 'slurp_file';
10 use Try::Tiny;
11 use lib 't/lib';
12 use make_dbictest_db ();
13 use dbixcsl_test_dir '$tdir';
14
15 plan tests => 2;
16
17 my $config_dir  = "$tdir/dbicdump_config";
18 make_path $config_dir;
19 my $config_file = "$config_dir/my.conf";
20
21 my $dump_path   = "$tdir/dbicdump_config_dump";
22
23 open my $fh, '>', $config_file
24     or die "Could not write to $config_file: $!";
25
26 print $fh <<"EOF";
27 schema_class DBICTest::Schema
28
29 lib t/lib
30
31 <connect_info>
32     dsn $make_dbictest_db::dsn
33 </connect_info>
34
35 <loader_options>
36     dump_directory    $dump_path
37     components        InflateColumn::DateTime
38     schema_base_class TestSchemaBaseClass
39     quiet             1
40 </loader_options>
41 EOF
42
43 close $fh;
44
45 system $^X, 'script/dbicdump', $config_file;
46
47 is $? >> 8, 0,
48     'dbicdump executed successfully';
49
50 my $foo = try { slurp_file "$dump_path/DBICTest/Schema/Result/Foo.pm" } || '';
51
52 like $foo, qr/InflateColumn::DateTime/,
53     'loader options read correctly from config_file';
54
55 done_testing;
56
57 END {
58     rmtree($config_dir, 1, 1);
59     rmtree($dump_path,  1, 1);
60 }