lib/Test2/Harness/UI/Controller/ReRun.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 84 CC 6 SCAR 29.5
CC
6
Cov
0%
handle
42.0
title
2.0
BEGIN
2.0
CRAP 19.1
1 package Test2::Harness::UI::Controller::ReRun;
2 use strict;
3 use warnings;
4  
5 our $VERSION = '0.000150';
6  
7 use Test2::Harness::UI::Response qw/resp error/;
8 use Test2::Harness::Util::JSON qw/encode_json encode_pretty_json decode_json/;
9 use Test2::Harness::UI::UUID qw/uuid_inflate/;
10  
11 use parent 'Test2::Harness::UI::Controller';
12 use Test2::Harness::UI::Util::HashBase;
13  
14 sub title { 'Rerun' }
15  
16 sub handle {
17 my $self = shift;
18 my ($route) = @_;
19  
20 my $req = $self->{+REQUEST};
21 my $res = resp(200);
22 $res->header('Cache-Control' => 'no-store');
23  
24 die error(404 => 'Missing route') unless $route;
25 my $run_id = $route->{run_id};
26 my $project_name = $route->{project};
27 my $username = $route->{username};
28  
29 if ($run_id) {
30 $run_id = uuid_inflate($run_id) or die error(404 => "Invalid run id");
31 }
32  
33 die error(404 => 'No source') unless $run_id || ($project_name && $username);
34 my $schema = $self->{+CONFIG}->schema;
35  
36 my $query = {};
37 my $attrs = {order_by => {'-desc' => 'run_ord'}, rows => 1};
38  
39 my $run;
40 my $ok = eval {
41 $run = $schema->vague_run_search(
42 query => $query,
43 attrs => $attrs,
44  
45 username => $username,
46 project_name => $project_name,
47 source => $run_id,
48 );
49 1;
50 };
51 my $err = $@;
52 die error(400 => "Invalid Request: $err") unless $ok;
53 die error(404 => 'No Data') unless $run;
54  
55 my $data = $run->rerun_data;
56  
57 $res->content_type('application/json');
58 $res->raw_body($data);
59 return $res;
60 }
61  
62 1;
63  
64 __END__