Branch Coverage

lib/Net/API/CPAN/Mock.pm
Criterion Covered Total %
branch 279 518 53.8


line true false branch
48 2 0 unless exists $self->{'checksum'}
50 2 0 unless exists $self->{'endpoints'}
51 2 0 unless exists $self->{'host'}
53 2 0 unless exists $self->{'openapi'}
54 2 0 unless exists $self->{'port'}
55 2 0 unless exists $self->{'pretty'}
57 2 0 unless exists $self->{'specs'}
59 0 2 unless $self->SUPER::init(@_)
60 0 2 if ($self->{'specs'})
62 0 0 unless $self->load_specs($self->{'specs'})
65 0 2 if $self->pretty
66 2 0 unless ($Net::API::CPAN::Mock::TEST_DATA)
68 0 2 unless &Encode::is_utf8($Net::API::CPAN::Mock::DATA)
70 0 2 if ($@)
83 2 6 unless ($socket = $self->socket)
88 0 2 unless CORE::socket $s, 2, 1, $proto
100 0 2 unless CORE::bind $s, $addr
101 0 2 unless listen $s, 10
120 2 3 if (@_) { }
126 0 3 unless $self->bind
138 0 2 if (not $file->exists) { }
0 2 elsif (not $file->is_file) { }
0 2 elsif ($file->is_empty) { }
151 0 0 if ($self->{'checksum'} and $self->{'checksum'} eq $checksum and $self->{'specs'} and ref $self->{'specs'} eq "HASH" and scalar keys %{$$self{"specs"};})
157 0 0 if $self->_is_warnings_enabled
162 0 2 if not defined $paths or ref $paths ne "HASH"
177 0 782 if (ref $schema eq "HASH" and exists $$processed{$self->_refaddr($schema)})
183 0 782 if ref $schema
187 0 782 if (lc(substr($schema, 0, 4) // "") eq "http")
191 0 782 unless substr($schema, 0, 2) eq "#/"
193 0 782 if (exists $seen->{$schema})
199 0 782 unless scalar @$frags
207 2346 0 if (exists $$tmp{$frags->[$i]}) { }
231 1918 6 if ($type eq 'hash') { }
6 0 elsif ($type eq 'array') { }
235 70 3948 if ($prop eq '$ref') { }
2636 1312 elsif (ref $ref->{$prop}) { }
243 1586 1050 if (++$$been_there{$self->_refaddr($ref->{$prop})} > 1)
247 0 1050 unless &$crawl($ref->{$prop}, "context", $ctx)
255 14 12 if (ref $ref->[$i])
257 0 14 if (++$$been_there{$self->_refaddr($ref->[$i])} > 1)
261 0 14 unless &$crawl($ref->[$i], "context", $ctx)
274 0 860 if ref $hash ne "HASH"
277 0 860 unless exists $opts->{'prefix'}
281 712 148 if (exists $hash->{'$ref'}) { }
80 68 elsif (exists $hash->{'properties'}) { }
0 68 elsif (exists $hash->{'type'} and defined $hash->{'type'} and $hash->{'type'} eq 'array') { }
68 0 elsif (exists $hash->{'type'}) { }
288 28 684 if (exists $schema_def->{'allOf'}) { }
0 684 elsif (not exists $schema_def->{'properties'}) { }
291 0 28 if (ref $schema_def->{'allOf'} ne "ARRAY")
299 0 56 if (ref $elem ne "HASH")
304 52 4 if (++$$circular_props{$self->_refaddr($elem)} > 1)
332 0 80 if (not exists $hash->{'type'} or $hash->{'type'} ne "object")
335 0 0 if $self->_is_warnings_enabled
386 0 0 if (not exists $hash->{'items'} && defined $hash->{'items'} or ref $hash->{'items'} ne "HASH")
395 0 0 if (exists $items->{'allOf'} or exists $items->{'anyOf'} or exists $items->{'oneOf'}) { }
401 0 0 unless exists $items->{$t}
435 0 860 if (not defined $props or ref $props ne "HASH")
442 0 860 unless &$crawl($props, "context", $ctx)
452 0 202 if ref $paths->{$path} ne "HASH"
461 140 246 if ($i % 2) { }
463 96 44 if ($i == $#parts) { }
480 400 408 unless exists $paths->{$path}{$meth}
481 202 206 unless exists $def->{$path}
484 0 408 if ref $this ne "HASH"
486 0 408 if (exists $$ids{$this->{'operationId'}})
496 0 730 unless defined $elem and ref $elem eq "HASH"
497 450 280 if ($elem->{'in'} eq 'query') { }
280 0 elsif ($elem->{'in'} eq 'path') { }
499 450 0 exists $elem->{'schema'} ? :
510 192 216 unless ($meth eq "get" or $meth eq "delete")
512 0 192 if (not exists $this->{'requestBody'}) { }
0 192 elsif (not defined $this->{'requestBody'} or ref $this->{'requestBody'} ne 'HASH') { }
0 192 elsif (not exists $this->{'requestBody'}{'content'} && defined $this->{'requestBody'}{'content'} or ref $this->{'requestBody'}{'content'} ne 'HASH') { }
527 0 192 if (not scalar keys %$cts) { }
539 0 408 if (not exists $this->{'responses'}) { }
0 408 elsif (not defined $this->{'responses'} or ref $this->{'responses'} ne 'HASH') { }
0 408 elsif (not scalar keys %{$$this{'responses'};}) { }
556 0 816 if (not defined $this->{'responses'}{$code} or ref $this->{'responses'}{$code} ne 'HASH') { }
0 816 elsif (not exists $this->{'responses'}{$code}{'content'}) { }
0 816 elsif (not defined $this->{'responses'}{$code}{'content'} or ref $this->{'responses'}{$code}{'content'} ne 'HASH') { }
574 0 856 if (not exists $this->{'responses'}{$code}{'content'}{$ct}{'schema'}) { }
0 856 elsif (not defined $this->{'responses'}{$code}{'content'}{$ct}{'schema'} or ref $this->{'responses'}{$code}{'content'}{$ct}{'schema'} ne 'HASH') { }
604 2 3 if (@_) { }
610 0 3 unless $self->bind
626 0 2 if $self->{'pid'}
629 1 1 if ($self->{'pid'}) { }
649 1 0 unless accept my $client, $socket
664 0 0 if ($req->headers->exists("Accept-Language"))
674 0 0 if $best
702 0 0 if (scalar @matches)
711 0 0 if (not defined $def) { }
0 0 elsif (not exists $def->{$meth}) { }
747 0 0 if ($meth eq 'delete' or $meth eq 'get' or $meth eq 'head') { }
753 0 0 unless (defined $ct and length($ct // ""))
769 0 0 unless (scalar grep(/^$ct$/i, @$ok_types))
785 0 0 if ($ct eq "application/json")
794 0 0 if ($@)
816 0 0 if (my $handler = $self->can("_$op_id")) { }
0 0 elsif (exists $data->{$op_id} or exists $alias->{$op_id}) { }
842 0 0 exists $alias->{$op_id} ? :
847 0 0 if (scalar @$resp_cts_ok == 1) { }
854 0 0 if ($req->headers->exists("Accept"))
859 0 0 if (exists $resp_cts->{$accept}) { }
880 0 0 if ($resp_ct eq 'application/json') { }
924 0 1 unless $self->{'pid'}
1009 0 2 unless (exists $form->{'id'})
1013 0 2 ref $form->{'id'} eq 'ARRAY' ? :
1017 0 2 unless exists $data->{'users'}{$id}
1018 0 2 unless exists $data->{'users'}{$id}{'is_pause_custodial_account'}
1065 2 2 unless index($user, $prefix) == 0
1067 0 2 unless $from == $n
1069 0 2 if scalar @$authors == $size
1106 0 2 unless exists $form->{'user'} and length $form->{'user'}
1107 0 2 ref $form->{'user'} eq 'ARRAY' ? :
1115 0 60 if (exists $$need{$data->{'users'}{$user}{'user'}})
1160 0 2 if exists $data->{'users'}{$user}
1199 0 2 unless (exists $data->{'users'}{$author})
1286 0 2 unless (exists $form->{'release'} and length $form->{'release'})
1291 0 2 ref $form->{'release'} eq 'ARRAY' ? :
1300 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'}{$module})
1354 2 42 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
1363 0 2 unless (defined $info)
1404 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'}{$module}) { }
1457 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'contributions'})
1502 0 0 if (exists $data->{'users'}{'modules'} and ref $data->{'users'}{'modules'} eq "HASH" and exists $data->{'users'}{'modules'}{$package} and ref $data->{'users'}{'modules'}{$package} eq "HASH" and exists $data->{'users'}{'modules'}{$package}{'contributors'} and ref $data->{'users'}{'modules'}{$package}{'contributors'} eq "ARRAY")
1560 2 44 if (exists $data->{'users'}{$user}{'modules'}{$package})
1635 0 46 unless exists $data->{'users'}{$user}{'modules'}
1636 2 44 if (exists $data->{'users'}{$user}{'modules'}{$package})
1666 0 2 if (defined $type and $type eq 'text/plain' or not $accept->is_empty and $accept->first eq 'text/plain') { }
1676 0 2 if ($return_type eq 'text/plain') { }
1689 0 168 unless exists $tags->{$1}
1696 2 0 if (defined $res) { }
1756 2 0 if (exists $data->{'users'}{$author1} and exists $data->{'users'}{$author2} and exists $data->{'users'}{$author1}{'modules'} and exists $data->{'users'}{$author2}{'modules'} and ref $data->{'users'}{$author1}{'modules'} eq "HASH" and ref $data->{'users'}{$author2}{'modules'} eq "HASH" and exists $data->{'users'}{$author1}{'modules'}{$package1} and exists $data->{'users'}{$author2}{'modules'}{$package2})
1795 0 2 if (defined $type and $type eq 'text/plain' or not $accept->is_empty and $accept->first eq 'text/plain') { }
1805 0 2 if ($return_type eq 'text/plain') { }
1818 0 168 unless exists $tags->{$1}
1823 2 0 if (defined $res) { }
1876 0 46 unless exists $data->{'users'}{$user}{'modules'}
1879 2 144 if (not defined $ref1 and $data->{'users'}{$user}{'modules'}{$package}{'id'} eq $file1)
1884 2 144 if (not defined $ref2 and $data->{'users'}{$user}{'modules'}{$package}{'id'} eq $file2)
1889 2 144 if defined $ref1 and defined $ref2
1893 2 0 if (defined $ref1 and defined $ref2) { }
1925 0 2 if ($type eq 'text/plain' or not $accept->is_empty and $accept->first eq 'text/plain') { }
1934 0 2 if ($return_type eq 'text/plain') { }
1947 0 168 unless exists $tags->{$1}
2021 2 44 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
2069 0 2 if (not defined $res) { }
2108 2 0 if exists $opts->{'distribution'} and $opts->{'distribution'}
2109 0 4 unless (exists $form->{'distribution'} and length $form->{'distribution'})
2114 0 4 ref $form->{'distribution'} eq 'ARRAY' ? :
2124 4 88 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
2141 4 0 if (scalar keys %$rivers)
2263 2 44 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$mod})
2349 2 0 if ($this->{'user'} eq $id and exists $this->{'modules'}{$module})
2365 0 2 unless (defined $res)
2402 2 0 unless ref $dist eq "ARRAY"
2414 2 58 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
2459 2 58 if ($data->{'users'}{$user}{'user'} eq $id)
2501 60 0 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH")
2507 10 186 unless exists $$top{$this->{'likes'}}
2569 22 0 if ($n >= $offset)
2577 2 20 if $n > $offset + $size
2624 2 58 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
2633 4 56 if ($user eq $author)
2770 0 46 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
2771 2 44 if (exists $data->{'users'}{$user}{'modules'}{$package})
2774 0 2 !length($path) || substr($path, -1, 1) eq '/' ? :
2796 2 0 $is_dir ? :
2 0 $path ? :
2812 0 2 unless (defined $res)
2855 0 2 if (substr($path, -1, 1) eq "/")
2869 0 0 if $dir_path ne $std_path
2872 0 0 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
2873 0 0 if (exists $data->{'users'}{$user}{'modules'}{$package})
3196 0 2 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3197 2 0 if (exists $data->{'users'}{$user}{'modules'}{$mod})
3205 0 2 unless (defined $res)
3337 0 2 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3338 2 0 if (exists $data->{'users'}{$user}{'modules'}{$package})
3346 0 2 unless (defined $res)
3388 0 2 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3389 2 0 if (exists $data->{'users'}{$user}{'modules'}{$mod})
3405 0 2 unless (defined $res)
3476 2 0 if (exists $data->{'users'}{$author})
3534 4 2 if exists $opts->{'module'}
3535 0 6 unless (exists $form->{'module'} and length($form->{'module'} // ""))
3542 0 6 ref $form->{'module'} eq 'ARRAY' ? :
3548 0 6 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3549 6 0 if (exists $data->{'users'}{$user}{'modules'}{$package})
3666 2 2 exists $opts->{'module'} ? :
3667 0 4 unless length($module // "")
3669 0 4 unless $type =~ m[^text/(?:html|plain|x-markdown|x-pod)$]i
3674 0 120 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3675 4 116 if (exists $data->{'users'}{$user}{'modules'}{$module})
3679 0 4 if ($type eq 'text/html') { }
4 0 elsif ($type eq 'text/plain') { }
0 0 elsif ($type eq 'text/x-markdown') { }
0 0 elsif ($type eq 'text/x-pod') { }
3891 0 2 unless exists $form->{'distribution'}
3892 0 2 ref $form->{'distribution'} eq 'ARRAY' ? :
3899 0 60 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
3900 2 58 if (exists $data->{'users'}{$user}{'modules'}{$package})
3903 2 0 unless defined $res
3917 0 2 unless (defined $res)
4055 0 4 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
4056 4 0 if (exists $data->{'users'}{$user}{'modules'}{$package})
4065 0 4 unless (defined $res)
4139 4 0 if (exists $data->{'users'}{$author})
4201 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH" and exists $data->{'users'}{$author}{'modules'}{$package})
4210 6 0 if (exists $data->{'users'}{$user})
4259 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH" and exists $data->{'users'}{$author}{'modules'}{$package})
4361 0 2 unless (defined $res)
4406 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH" and exists $data->{'users'}{$author}{'modules'}{$package})
4501 0 2 unless (defined $res)
4542 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH")
4598 2 58 if (exists $data->{'users'}{$user} and exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
4616 0 2 unless (defined $res)
4666 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH" and exists $data->{'users'}{$author}{'modules'}{$package})
4677 0 2 unless (defined $res)
4727 22 0 if ($n >= $offset)
4735 2 20 if $n > $offset + $size
4816 0 2 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
4817 2 0 if (exists $data->{'users'}{$user}{'modules'}{$package})
5100 0 30 unless exists $data->{'users'}{$user}{'modules'}
5104 1 97 if ($this->{'package'} =~ /^$q/)
5162 0 30 unless exists $data->{'users'}{$user}{'modules'}
5166 1 97 if ($this->{'package'} =~ /^$q/)
5180 0 1 unless (defined $res)
5240 0 30 unless exists $data->{'users'}{$user}{'modules'}
5246 0 97 if ($this->{'package'} =~ /$q/ or $this->{'abstract'} =~ /$q/ or $this->{'name'} =~ /$q/ or $this->{'distribution'} =~ /$q/)
5251 1 0 if ($offset >= $from)
5264 0 1 if scalar @$results == $size
5301 2 0 if (exists $data->{'users'}{$author} and exists $data->{'users'}{$author}{'modules'} and ref $data->{'users'}{$author}{'modules'} eq "HASH" and exists $data->{'users'}{$author}{'modules'}{$package})
5316 0 2 unless (defined $res)
5356 2 44 if (exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH" and exists $data->{'users'}{$user}{'modules'}{$package})
5374 0 2 unless (defined $res)
5403 1 3 unless ($recent = $self->{'_recent'})
5412 0 30 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
5423 0 98 if ($@)
5478 0 4 $info->{'authorized'} ? :
5479 0 4 $info->{'deprecated'} ? :
5503 1 46 if (exists $opts->{'query'} and defined $opts->{'query'} and length $opts->{'query'}) { }
23 23 elsif ($req->method eq 'POST' and $req->headers->type and $req->headers->type eq 'application/json') { }
5523 28 19 if (not length $q) { }
5525 0 28 if ($type eq 'author') { }
5533 0 840 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
5545 0 19 if (index($q, ':') != -1) { }
5555 6 13 if ($type eq 'author') { }
5560 0 174 if ($this->{'pauseid'} =~ /$re/ or $this->{'name'} =~ /$re/ or $this->{'email'} =~ /$re/ or $this->{'city'} =~ /$re/)
5573 0 390 unless exists $data->{'users'}{$user}{'modules'} and ref $data->{'users'}{$user}{'modules'} eq "HASH"
5577 0 1274 if (defined $prop) { }
19 1255 elsif ($this->{'abstract'} =~ /$re/ or $this->{'author'} =~ /$re/ or $this->{'distribution'} =~ /$re/ or $this->{'id'} =~ /$re/ or $this->{'name'} =~ /$re/ or $this->{'package'} =~ /$re/ or exists $this->{'provides'} and ref $this->{'provides'} eq 'ARRAY' and join(' ', @{$this->{'provides'};}) =~ /$re/) { }
5579 0 0 if ($this->{$prop} =~ /$re/)
5605 28 277 if scalar @$hits == $size
5625 14 33 if ($opts->{'scroll'})
5646 0 0 if ($self->pid)
5648 0 0 unless $self->stop