From Code to Community: Sponsoring The Perl and Raku Conference 2025 Learn more

#
# (c) Jan Gehring <jan.gehring@gmail.com>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:
use 5.010001;
use strict;
our $VERSION = '1.13.0.2'; # TRIAL VERSION
use Rex -minimal;
sub new {
my $that = shift;
my $proto = ref($that) || $that;
my $self = {@_};
bless( $self, $proto );
my ( $pkg, $file ) = caller(0);
return $self;
}
sub run_test {
my ( $self, $user, $key, $value, $count ) = @_;
my @crons = cron list => $user;
my @matched_crons = grep { $_->{$key} eq $value } @crons;
if ($count) {
$self->ok( scalar @matched_crons == $count,
"Found $count cron(s) with $key = $value" );
}
else {
$self->ok( scalar @matched_crons > 0, "Found cron with $key = $value" );
}
}
sub run_not_test {
my ( $self, $user, $key, $value, $count ) = @_;
my @crons = cron list => $user;
my @matched_crons = grep { $_->{$key} eq $value } @crons;
if ($count) {
$self->ok( scalar @matched_crons != $count,
"Not found $count cron(s) with $key = $value" );
}
else {
$self->ok( scalar @matched_crons == 0,
"Not found cron with $key = $value" );
}
}
1;