File Coverage

lib/Rex/Test/Base/has_cron.pm
Criterion Covered Total %
statement 14 34 41.1
branch 0 4 0.0
condition 0 3 0.0
subroutine 5 8 62.5
pod 1 3 33.3
total 20 52 38.4


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Test::Base::has_cron;
6              
7 1     1   15 use v5.12.5;
  1         4  
8 1     1   6 use warnings;
  1         2  
  1         45  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   10 use Rex -minimal;
  1         3  
  1         6  
13 1     1   9 use Rex::Commands::Cron;
  1         2  
  1         6  
14              
15 1     1   6 use base qw(Rex::Test::Base);
  1         3  
  1         408  
16              
17             sub new {
18 0     0 1   my $that = shift;
19 0   0       my $proto = ref($that) || $that;
20 0           my $self = {@_};
21              
22 0           bless( $self, $proto );
23              
24 0           my ( $pkg, $file ) = caller(0);
25              
26 0           return $self;
27             }
28              
29             sub run_test {
30 0     0 0   my ( $self, $user, $key, $value, $count ) = @_;
31              
32 0           my @crons = cron list => $user;
33 0           my @matched_crons = grep { $_->{$key} eq $value } @crons;
  0            
34              
35 0 0         if ($count) {
36 0           $self->ok( scalar @matched_crons == $count,
37             "Found $count cron(s) with $key = $value" );
38             }
39             else {
40 0           $self->ok( scalar @matched_crons > 0, "Found cron with $key = $value" );
41             }
42             }
43              
44             sub run_not_test {
45 0     0 0   my ( $self, $user, $key, $value, $count ) = @_;
46              
47 0           my @crons = cron list => $user;
48 0           my @matched_crons = grep { $_->{$key} eq $value } @crons;
  0            
49              
50 0 0         if ($count) {
51 0           $self->ok( scalar @matched_crons != $count,
52             "Not found $count cron(s) with $key = $value" );
53             }
54             else {
55 0           $self->ok( scalar @matched_crons == 0,
56             "Not found cron with $key = $value" );
57             }
58             }
59              
60             1;