Add tab test to all my modules
[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;
f9d8e3cf 9
10plan tests => 6;
11use Catalyst::Test 'TestApp';
12
13our $STATE = "$FindBin::Bin/lib/TestApp/scheduler.state";
14
15TestApp->schedule(
16 trigger => 'every_minute',
17 event => '/cron/every_minute',
18);
19
20# disallow localhost
21TestApp->config->{scheduler}->{hosts_allow} = '1.2.3.4';
22
23# test that the event does not execute
24{
25 ok( my $res = request('http://localhost/?schedule_trigger=every_minute'), 'request ok' );
26 is( $res->content, 'default', 'response ok' );
27 is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", undef, 'every_minute did not execute, ok' );
28 unlink "$FindBin::Bin/lib/TestApp/every_minute.log";
29}
30
31# allow localhost
32TestApp->config->{scheduler}->{hosts_allow} = [ '1.2.3.4', '127.0.0.1' ];
33
34# test that the event does execute
35{
36 ok( my $res = request('http://localhost/?schedule_trigger=every_minute'), 'request ok' );
37 is( $res->content, 'default', 'response ok' );
38 is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", 1, 'every_minute executed ok' );
39 unlink "$FindBin::Bin/lib/TestApp/every_minute.log";
40}