Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions lib/OpenQA/WebAPI/Plugin/ObsRsync/Controller/Folders.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
# SPDX-License-Identifier: GPL-2.0-or-later

package OpenQA::WebAPI::Plugin::ObsRsync::Controller::Folders;
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Base 'Mojolicious::Controller', -signatures;
use Mojo::File;
use POSIX 'strftime';

my $non_project_folders = '^(t|profiles|script|xml)$';

sub list {
my $self = shift;
sub list ($self) {
my $helper = $self->obs_rsync;
my $folders = Mojo::File->new($helper->home)->list({dir => 1})->grep(sub { -d $_ })->map('basename')->to_array;
my @res;
Expand All @@ -26,8 +25,7 @@ sub list {
return $self->render(json => \@res, status => 200);
}

sub index {
my ($self, $obs_project, $folders) = @_;
sub index ($self, $obs_project, $folders) {
my $helper = $self->obs_rsync;
my %folder_info_by_name;
if (!$folders) {
Expand Down Expand Up @@ -85,8 +83,7 @@ sub index {
$self->render('ObsRsync_index', folder_info_by_name => \%folder_info_by_name, project => $obs_project);
}

sub folder {
my $self = shift;
sub folder ($self) {
my $alias = $self->param('alias');
my $helper = $self->obs_rsync;
return undef if $helper->check_and_render_error($alias);
Expand All @@ -113,8 +110,7 @@ sub folder {
openqa_sh => $files->grep(qr/print_openqa\.sh/)->join());
}

sub runs {
my $self = shift;
sub runs ($self) {
my $alias = $self->param('alias');
my $helper = $self->obs_rsync;
return undef if $helper->check_and_render_error($alias);
Expand All @@ -126,8 +122,7 @@ sub runs {
$self->render('ObsRsync_logs', alias => $alias, full => $full->to_string, subfolders => $files);
}

sub run {
my $self = shift;
sub run ($self) {
my $alias = $self->param('alias');
my $subfolder = $self->param('subfolder');
my $helper = $self->obs_rsync;
Expand All @@ -145,8 +140,7 @@ sub run {
);
}

sub download_file {
my $self = shift;
sub download_file ($self) {
my $alias = $self->param('alias');
my $subfolder = $self->param('subfolder');
my $filename = $self->param('filename');
Expand All @@ -159,8 +153,7 @@ sub download_file {
$self->reply->file($full->child($filename));
}

sub get_run_last {
my $self = shift;
sub get_run_last ($self) {
my $alias = $self->param('alias');
my $helper = $self->obs_rsync;
return undef if $helper->check_and_render_error($alias);
Expand All @@ -172,8 +165,7 @@ sub get_run_last {
return $self->render(json => {message => $run_last}, status => 200);
}

sub forget_run_last {
my $self = shift;
sub forget_run_last ($self) {
my $alias = $self->param('alias');
my $helper = $self->obs_rsync;
return undef if $helper->check_and_render_error($alias);
Expand All @@ -189,11 +181,11 @@ sub forget_run_last {
if (unlink($dest)) {
return $self->render(json => {message => 'success'}, status => 200);
}
# uncoverable statement
return $self->render(json => {message => "error $!"}, status => 500);
Comment on lines +184 to 185
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably possible to write a test covering this line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, I just follow the suggestion by tina to mark most of them uncoverable, but I'll work on testing it if you want 👍

}

sub test_result {
my $self = shift;
sub test_result ($self) {
my $alias = $self->param('alias');
my $helper = $self->obs_rsync;
return undef if $helper->check_and_render_error($alias);
Expand Down