Commit | Line | Data |
f9d8e3cf |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | use Test::More; |
f9d8e3cf |
9 | |
10 | plan tests => 6; |
11 | use Catalyst::Test 'TestApp'; |
12 | |
13 | our $STATE = "$FindBin::Bin/lib/TestApp/scheduler.state"; |
14 | |
15 | TestApp->schedule( |
16 | trigger => 'every_minute', |
17 | event => '/cron/every_minute', |
18 | ); |
19 | |
20 | # disallow localhost |
21 | TestApp->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 |
32 | TestApp->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 | } |