Commit | Line | Data |
406a97c2 |
1 | use DBIx::Class::Schema::Loader::Optional::Dependencies |
2 | -skip_all_without => 'test_dbicdump_config'; |
0322c5b3 |
3 | |
4 | use strict; |
5 | use warnings; |
6 | |
7 | use Test::More; |
8 | use File::Path qw/make_path rmtree/; |
0322c5b3 |
9 | use DBIx::Class::Schema::Loader::Utils 'slurp_file'; |
112415f1 |
10 | use Try::Tiny; |
0322c5b3 |
11 | use lib 't/lib'; |
12 | use make_dbictest_db (); |
13 | use dbixcsl_test_dir '$tdir'; |
14 | |
0322c5b3 |
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 | |
112415f1 |
29 | lib t/lib |
30 | |
0322c5b3 |
31 | <connect_info> |
32 | dsn $make_dbictest_db::dsn |
33 | </connect_info> |
34 | |
35 | <loader_options> |
112415f1 |
36 | dump_directory $dump_path |
37 | components InflateColumn::DateTime |
38 | schema_base_class TestSchemaBaseClass |
39 | quiet 1 |
0322c5b3 |
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 | |
112415f1 |
50 | my $foo = try { slurp_file "$dump_path/DBICTest/Schema/Result/Foo.pm" } || ''; |
0322c5b3 |
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 | } |