Commit | Line | Data |
0322c5b3 |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use File::Path qw/make_path rmtree/; |
0322c5b3 |
8 | use DBIx::Class::Schema::Loader::Utils 'slurp_file'; |
112415f1 |
9 | use Try::Tiny; |
10 | use namespace::clean; |
11 | use DBIx::Class::Schema::Loader::Optional::Dependencies (); |
0322c5b3 |
12 | use lib 't/lib'; |
13 | use make_dbictest_db (); |
14 | use dbixcsl_test_dir '$tdir'; |
15 | |
16 | BEGIN { |
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 | |
22 | plan tests => 2; |
23 | |
24 | my $config_dir = "$tdir/dbicdump_config"; |
25 | make_path $config_dir; |
26 | my $config_file = "$config_dir/my.conf"; |
27 | |
28 | my $dump_path = "$tdir/dbicdump_config_dump"; |
29 | |
30 | open my $fh, '>', $config_file |
31 | or die "Could not write to $config_file: $!"; |
32 | |
33 | print $fh <<"EOF"; |
34 | schema_class DBICTest::Schema |
35 | |
112415f1 |
36 | lib 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> |
48 | EOF |
49 | |
50 | close $fh; |
51 | |
52 | system $^X, 'script/dbicdump', $config_file; |
53 | |
54 | is $? >> 8, 0, |
55 | 'dbicdump executed successfully'; |
56 | |
112415f1 |
57 | my $foo = try { slurp_file "$dump_path/DBICTest/Schema/Result/Foo.pm" } || ''; |
0322c5b3 |
58 | |
59 | like $foo, qr/InflateColumn::DateTime/, |
60 | 'loader options read correctly from config_file'; |
61 | |
62 | done_testing; |
63 | |
64 | END { |
65 | rmtree($config_dir, 1, 1); |
66 | rmtree($dump_path, 1, 1); |
67 | } |