Commit | Line | Data |
68f800bd |
1 | #!perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | use Test::More; |
9 | use Storable qw/lock_store lock_retrieve/; |
10 | |
ecf6a062 |
11 | plan tests => 6; |
68f800bd |
12 | use Catalyst::Test 'TestApp'; |
13 | |
14 | our $STATE = "$FindBin::Bin/lib/TestApp/scheduler.state"; |
15 | |
16 | # hack the last event check to make all events execute immediately |
17 | my $state = { last_check => 0 }; |
18 | lock_store $state, $STATE; |
19 | |
20 | # configure a yaml file |
8c698cac |
21 | TestApp->config->{scheduler}->{yaml_file} |
22 | = "$FindBin::Bin/lib/TestApp/test.yml"; |
68f800bd |
23 | |
24 | # test that the plugin event executes |
25 | { |
26 | ok( my $res = request('http://localhost/'), 'request ok' ); |
27 | is( $res->content, 'default', 'response ok' ); |
28 | is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", 1, 'every_minute executed ok' ); |
29 | unlink "$FindBin::Bin/lib/TestApp/every_minute.log"; |
30 | } |
31 | |
ecf6a062 |
32 | # test that a YAML trigger works |
33 | { |
34 | ok( my $res = request('http://localhost/?schedule_trigger=some_long_trigger_name'), 'request ok' ); |
35 | is( $res->content, 'default', 'response ok' ); |
36 | is( -e "$FindBin::Bin/lib/TestApp/every_minute.log", 1, 'every_minute executed ok' ); |
37 | unlink "$FindBin::Bin/lib/TestApp/every_minute.log"; |
38 | } |
39 | |