-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add healthcheck page at /status/health
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use FixMyStreet::TestMech; | ||
use Test::MockModule; | ||
|
||
|
||
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' ); | ||
|
||
my $surrey = $mech->create_body_ok(2242, 'Surrey County Council'); | ||
(my $report) = $mech->create_problems_for_body(1, $surrey->id, 'Pothole', { | ||
category => 'Potholes', cobrand => 'surrey', | ||
latitude => 51.293415, longitude => -0.441269, areas => '2242', | ||
}); | ||
|
||
|
||
subtest 'Health page returns 200 when things are OK' => sub { | ||
$mech->get_ok('/status/health'); | ||
is $mech->content, 'OK: ' . $report->id, 'Got correct content for status page'; | ||
is $mech->res->code, 200, 'Got 200 for status page'; | ||
}; | ||
|
||
subtest 'Health page returns 500 when things are not OK' => sub { | ||
my $rs = Test::MockModule->new('FixMyStreet::DB::ResultSet::Problem'); | ||
$rs->mock('first', sub { die 'DB error' }); | ||
$mech->get('/status/health'); | ||
is $mech->res->code, 500, 'Got 500 for status page'; | ||
}; | ||
|
||
|
||
done_testing(); |