Skip to content

Commit

Permalink
Test what happens when we don't have connection info
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cross committed Aug 20, 2019
1 parent 33c25a2 commit eced7fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions t/Test/Lystyng/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ sub check_connect : Tests {
isa_ok($sch, 'Lystyng::Schema');
}

sub broken_connect : Tests {
my $self = shift;

local %ENV;

for (qw[ HOST NAME USER PASS ]) {
delete $ENV{"LYSTYNG_DB_$_"};
}

$self->_clear_schema;
my $sch = eval { $self->schema };

ok($@, 'Schema error with missing env variables');
}

sub check_rs : Tests {
my $sch = shift->schema;

Expand Down
3 changes: 2 additions & 1 deletion t/Test/Role/WithSchema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ has schema => (
isa => 'Lystyng::Schema',
lazy => 1,
builder => '_build_schema',
clearer => '_clear_schema',
);

sub _build_schema {
my $schema = eval { Lystyng::Schema->get_schema };
BAIL_OUT($@) if $@;
die ($@) if $@;
return $schema;
}

Expand Down

0 comments on commit eced7fd

Please sign in to comment.