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