prep for release
[catagits/Catalyst-Plugin-Scheduler.git] / t / 06trigger.t
CommitLineData
f9d8e3cf 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
7use lib "$FindBin::Bin/lib";
8use Test::More;
bec4be8c 9use Storable qw/lock_store lock_retrieve/;
f9d8e3cf 10
11plan tests => 6;
12use Catalyst::Test 'TestApp';
13
14our $STATE = "$FindBin::Bin/lib/TestApp/scheduler.state";
15
16TestApp->schedule(
17 trigger => 'every_minute',
18 event => '/cron/every_minute',
19);
20
21# disallow localhost
22TestApp->config->{scheduler}->{hosts_allow} = '1.2.3.4';
23
24# test that the event does not execute
25{
26 ok( my $res = request('http://localhost/?schedule_trigger=every_minute'), 'request ok' );
27 is( $res->content, 'default', 'response ok' );
28 is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", undef, 'every_minute did not execute, ok' );
29 unlink "$FindBin::Bin/lib/TestApp/every_minute.log";
30}
31
32# allow localhost
33TestApp->config->{scheduler}->{hosts_allow} = [ '1.2.3.4', '127.0.0.1' ];
34
35# test that the event does execute
36{
37 ok( my $res = request('http://localhost/?schedule_trigger=every_minute'), 'request ok' );
38 is( $res->content, 'default', 'response ok' );
39 is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", 1, 'every_minute executed ok' );
40 unlink "$FindBin::Bin/lib/TestApp/every_minute.log";
41}