From aee2a34685ee33d877b1e3219fdfae4313ef59b5 Mon Sep 17 00:00:00 2001 From: Ian Sillitoe Date: Mon, 30 Oct 2017 12:15:30 +0000 Subject: [PATCH] Use hashref (not hash) for connection info options --- script/dbicdump | 2 +- t/61dbicdump_config_options.t | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 t/61dbicdump_config_options.t diff --git a/script/dbicdump b/script/dbicdump index 80ade3560..2e0879fa8 100644 --- a/script/dbicdump +++ b/script/dbicdump @@ -158,7 +158,7 @@ if (@ARGV == 1) { make_schema_at( $c->{schema_class}, $c->{loader_options} || {}, - [ $dsn, $user, $pass, %{$options} ], + [ $dsn, $user, $pass, $options ], ); } else { diff --git a/t/61dbicdump_config_options.t b/t/61dbicdump_config_options.t new file mode 100644 index 000000000..c9425a6f7 --- /dev/null +++ b/t/61dbicdump_config_options.t @@ -0,0 +1,65 @@ +use DBIx::Class::Schema::Loader::Optional::Dependencies + -skip_all_without => 'test_dbicdump_config'; + +use strict; +use warnings; + +use Test::More; +use File::Path qw/make_path rmtree/; +use DBIx::Class::Schema::Loader::Utils 'slurp_file'; +use Try::Tiny; +use namespace::clean; +use lib 't/lib'; +use make_dbictest_db (); +use dbixcsl_test_dir '$tdir'; + +plan tests => 2; + +my $config_dir = "$tdir/dbicdump_config"; +make_path $config_dir; +my $config_file = "$config_dir/my.conf"; + +my $dump_path = "$tdir/dbicdump_config_dump"; + +open my $fh, '>', $config_file + or die "Could not write to $config_file: $!"; + +print $fh <<"EOF"; +schema_class DBICTest::Schema + +lib t/lib + + + dsn $make_dbictest_db::dsn + + LongReadLen 100000000 + LongTrunkOk 1 + + + + + dump_directory $dump_path + components InflateColumn::DateTime + schema_base_class TestSchemaBaseClass + quiet 1 + +EOF + +close $fh; + +system $^X, 'script/dbicdump', $config_file; + +is $? >> 8, 0, + 'dbicdump executed successfully'; + +my $foo = try { slurp_file "$dump_path/DBICTest/Schema/Result/Foo.pm" } || ''; + +like $foo, qr/InflateColumn::DateTime/, + 'loader options read correctly from config_file'; + +done_testing; + +END { + rmtree($config_dir, 1, 1); + rmtree($dump_path, 1, 1); +}