add self to credits
[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 namespace::clean;
12 use lib 't/lib';
13 use make_dbictest_db ();
14 use dbixcsl_test_dir '$tdir';
15
16 plan tests => 2;
17
18 my $config_dir  = "$tdir/dbicdump_config";
19 make_path $config_dir;
20 my $config_file = "$config_dir/my.conf";
21
22 my $dump_path   = "$tdir/dbicdump_config_dump";
23
24 open my $fh, '>', $config_file
25     or die "Could not write to $config_file: $!";
26
27 print $fh <<"EOF";
28 schema_class DBICTest::Schema
29
30 lib t/lib
31
32 <connect_info>
33     dsn $make_dbictest_db::dsn
34 </connect_info>
35
36 <loader_options>
37     dump_directory    $dump_path
38     components        InflateColumn::DateTime
39     schema_base_class TestSchemaBaseClass
40     quiet             1
41 </loader_options>
42 EOF
43
44 close $fh;
45
46 system $^X, 'script/dbicdump', $config_file;
47
48 is $? >> 8, 0,
49     'dbicdump executed successfully';
50
51 my $foo = try { slurp_file "$dump_path/DBICTest/Schema/Result/Foo.pm" } || '';
52
53 like $foo, qr/InflateColumn::DateTime/,
54     'loader options read correctly from config_file';
55
56 done_testing;
57
58 END {
59     rmtree($config_dir, 1, 1);
60     rmtree($dump_path,  1, 1);
61 }