Skip to content

Commit

Permalink
Move 'dsn' function to only place used'
Browse files Browse the repository at this point in the history
Tests did not cover the 'dsn' function anyway.
  • Loading branch information
okurz committed Jul 23, 2024
1 parent 468dc67 commit e5501d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
5 changes: 0 additions & 5 deletions lib/OpenQA/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ sub disconnect_db () {
$SINGLETON = undef;
}

sub dsn {
my $self = shift;
return $self->storage->connect_info->[0]->{dsn};
}

sub deploy ($self, $force_overwrite = 0) {
# lock config file to ensure only one thing will deploy/upgrade DB at once
# we use a file in prjdir/db as the lock file as the install process and
Expand Down
9 changes: 5 additions & 4 deletions lib/OpenQA/Shared/Plugin/Gru.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ sub register ($self, $app, $config) {
my $schema = $app->schema;

my $conn = Mojo::Pg->new;
if (ref $schema->storage->connect_info->[0] eq 'HASH') {
my $connect_info = $schema->storage->connect_info->[0];
if (ref $connect_info eq 'HASH') {
$self->dsn($schema->dsn);
$conn->username($schema->storage->connect_info->[0]->{user});
$conn->password($schema->storage->connect_info->[0]->{password});
$conn->username($connect_info->{user});
$conn->password($connect_info->{password});

Check warning on line 52 in lib/OpenQA/Shared/Plugin/Gru.pm

View check run for this annotation

Codecov / codecov/patch

lib/OpenQA/Shared/Plugin/Gru.pm#L51-L52

Added lines #L51 - L52 were not covered by tests
}
else {
$self->dsn($schema->storage->connect_info->[0]);
$self->dsn($connect_info);
}
$conn->dsn($self->dsn());

Expand Down

0 comments on commit e5501d7

Please sign in to comment.