33 lines
855 B
Perl
33 lines
855 B
Perl
use Mojo::Base -strict;
|
|
|
|
use Test2::V0;
|
|
use Test2::Plugin::BailOnFail;
|
|
use Test::Mojo;
|
|
|
|
my $t = Test::Mojo->new('MyApp');
|
|
|
|
# Page zero gets a redirect.
|
|
$t->get_ok('/0')->status_is(302);
|
|
|
|
# Now follow redirects and verify it's a 404.
|
|
$t->ua->max_redirects(10);
|
|
$t->get_ok('/0')->status_is(404);
|
|
|
|
# A too-high page number should take us to the last page.
|
|
$t->get_ok('/999?title_like=qxqxqxqx')->status_is(200)
|
|
->content_like(qr/0\s+books\s+of\s+0/);
|
|
|
|
# Likewise for invalid page numbers.
|
|
$t->get_ok('/x')->status_is(404);
|
|
$t->get_ok('/1.99')->status_is(404);
|
|
$t->get_ok('/-42')->status_is(404);
|
|
|
|
# Or non-existent author.
|
|
$t->get_ok('/author/0/1')->status_is(404);
|
|
|
|
# Invalid number of books for authors.
|
|
$t->get_ok('/authors/1?minimum_book_count=banana')->status_is(404);
|
|
$t->get_ok('/authors/1?minimum_book_count=-2')->status_is(404);
|
|
|
|
done_testing();
|