Skip to content

Commit

Permalink
[
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Nov 20, 2017
1 parent 83cc8b0 commit 0c17e3f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,12 @@ sub _init_config {
my $connector = shift;
confess "Deprecated connector" if $connector;

$CONFIG = YAML::LoadFile($file);
die "ERROR: Missing config file $file\n"
if !-e $file;

eval { $CONFIG = YAML::LoadFile($file) };

die "ERROR: Format error in config file $file\n$@" if $@;

$LIMIT_PROCESS = $CONFIG->{limit_process}
if $CONFIG->{limit_process} && $CONFIG->{limit_process}>1;
Expand Down
12 changes: 12 additions & 0 deletions t/05_ravada.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ ok($Ravada::CONNECTOR, "Now we should have a DB connector ");
ok($Ravada::CONNECTOR,"No connector defined ");
eval { ok($Ravada::CONNECTOR->dbh,"No dbh defined ") };

eval {
my $config_err = "t/etc/ravada_miss.conf";
my $rvd_err = Ravada->new( connector => $test->connector, config => $config_err);
};
like($@,qr/Missing config file/);

eval {
my $config_err = "t/etc/ravada_err.conf";
my $rvd_err = Ravada->new( connector => $test->connector, config => $config_err);
};
like($@,qr/Format error/);

done_testing();

0 comments on commit 0c17e3f

Please sign in to comment.