Tapper/API/Plugin/Unittest.pm

filter: Statementstmt 89.2% 25 / 28 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 84.6% 33 / 39 CC 4 SCAR 10.1
CC
4
Cov
82%
__ANON__
4.5
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« Tapper/API/Plugin/Integrationtest.pm ↑ Summary Mojolicious/Plugin/TapperConfig.pm »
1 package Tapper::API::Plugin::Unittest;
2 1 our $AUTHORITY = 'cpan:TAPPER';
3 1 $Tapper::API::Plugin::Unittest::VERSION = '5.0.2';
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Mojolicious::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶put 'unit-test/:testrun' => sub {
Subroutine __ANON__: called CC=4 SCAR=15.0
11 1 my $self = shift;
12 1 $self->app->renderer->default_format('json');
13  
14  
15 1 my $data;
16 1 ▶ if ($self->tx->req->body) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tx->req->body) 1 0 1
17 1 require JSON::XS;
18 1 $data = eval{JSON::XS::decode_json($self->tx->req->body)};
19 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
20 0 $self->render(json => {
21 error => $@
22 },
23 status => 409,
24 );
25 0 return;
26 }
27 }
28 1 ▶ if (not $data->{foo} eq 'bar') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data->{"foo"} eq "bar") 0 1 1
29 0 $self->render(json => {
30 error => "Can not find key 'foo' with value 'bar' in JSON body",
31 },
32 status => 409,
33 );
34 }
35 1 $self->respond_to(json => {json => {key => 'value'},
36 status => 202,
37 },
38 );
39 1 };
40  
41 1 1;
42  
43 __END__
« Tapper/API/Plugin/Integrationtest.pm ↑ Summary Mojolicious/Plugin/TapperConfig.pm »