The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

use Kelp::Base -strict;
use lib 't/lib';
my $app = JsonError->new;
my $t = Kelp::Test->new(app => $app);
# Check if json encoding does not cause json response enconding error (json
# content type + non-reference body). This happened in the past because json
# content type was set before encoding and not cleared when an error occured.
subtest 'testing mode development' => sub {
$app->mode('development');
$t->request(GET '/json')
->code_is(500)
->content_unlike(qr{Don't know how to handle non-json reference});
$t->request(GET '/forced-json')
->code_is(500)
->content_unlike(qr{Don't know how to handle non-json reference});
};
subtest 'testing mode deployment' => sub {
$app->mode('deployment');
$t->request(GET '/json')
->code_is(500)
->content_like(qr{Five Hundred});
$t->request(GET '/forced-json')
->code_is(500)
->content_like(qr{Five Hundred});
};
done_testing;