use FindBin;
use lib "$FindBin::Bin/lib";
use Test::More;
+use Storable qw/lock_store lock_retrieve/;
plan tests => 10;
-
use Catalyst::Test 'TestApp';
+our $STATE = "$FindBin::Bin/lib/TestApp/scheduler.state";
+
TestApp->schedule(
at => '* * * * *',
event => '/cron/every_minute',
);
# hack the last event check to make all events execute immediately
-TestApp->_last_event_check( 0 );
+my $state = { last_check => 0 };
+lock_store $state, $STATE;
# test that all events execute, and that the error test doesn't break the app
{
{
ok( my $res = request('http://localhost/'), 'request ok' );
is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", undef, 'every_minute did not execute, ok' );
+ unlink "$FindBin::Bin/lib/TestApp/every_minute.log";
is( -e "$FindBin::Bin/lib/TestApp/every_hour.log", undef, 'every_hour did not execute, ok' );
+ unlink "$FindBin::Bin/lib/TestApp/every_hour.log";
}
# jump back in time by 2 hours, make sure both events run
{
- my $last = TestApp->_last_event_check;
- TestApp->_last_event_check( $last - ( 60 * 120 ) );
+ my $state = lock_retrieve $STATE;
+ $state->{last_check} -= 60 * 120;
+ lock_store $state, $STATE;
ok( my $res = request('http://localhost/'), 'request ok' );
is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", 1, 'every_minute executed ok' );