Get tests passing again.
This commit is contained in:
parent
4c6d5bf321
commit
4c5626c9ef
13
t/basic.t
13
t/basic.t
|
@ -1,20 +1,13 @@
|
||||||
use Mojo::Base -strict;
|
use Mojo::Base -strict;
|
||||||
|
|
||||||
use Test2::V0;
|
use Test2::V0;
|
||||||
|
use Test2::Plugin::BailOnFail;
|
||||||
use Test::Mojo;
|
use Test::Mojo;
|
||||||
|
|
||||||
my $t = Test::Mojo->new('MyApp');
|
my $t = Test::Mojo->new('MyApp');
|
||||||
$t->get_ok('/')->status_is(200)->content_like(qr/home/i);
|
$t->get_ok('/')->status_is(200)->content_like(qr/Books/);
|
||||||
$t->get_ok('/about')->status_is(200)->content_like(qr/about/i);
|
$t->get_ok('/about')->status_is(200)->content_like(qr/about/i);
|
||||||
# No way to follow the redirect?
|
$t->get_ok('/1')->status_is(200)->content_like(qr/[[:digit:]] books/i);
|
||||||
$t->get_ok('/account')->status_is(302);
|
|
||||||
$t->get_ok('/auth')->status_is(200)->content_like(qr/login/i);
|
|
||||||
$t->post_ok('/login' => form => { logname => 'Dobby' });
|
|
||||||
$t->get_ok('/account')->status_is(200)->content_like(qr/dobby/i);
|
|
||||||
$t->get_ok('/books/1')->status_is(200)->content_like(qr/[[:digit:]] books/i);
|
|
||||||
$t->get_ok('/authors/1')->status_is(200)->content_like(qr/[[:digit:]] authors/i);
|
$t->get_ok('/authors/1')->status_is(200)->content_like(qr/[[:digit:]] authors/i);
|
||||||
$t->get_ok('/logout')->status_is(302);
|
|
||||||
# Can't do "content_unlike()" so check it offers login now.
|
|
||||||
$t->get_ok('/')->status_is(200)->content_like(qr/login/i);
|
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
16
t/notfound.t
16
t/notfound.t
|
@ -1,24 +1,26 @@
|
||||||
use Mojo::Base -strict;
|
use Mojo::Base -strict;
|
||||||
|
|
||||||
use Test2::V0;
|
use Test2::V0;
|
||||||
|
use Test2::Plugin::BailOnFail;
|
||||||
use Test::Mojo;
|
use Test::Mojo;
|
||||||
|
|
||||||
my $t = Test::Mojo->new('MyApp');
|
my $t = Test::Mojo->new('MyApp');
|
||||||
|
|
||||||
# Page zero gets a redirect.
|
# Page zero gets a redirect.
|
||||||
$t->get_ok('/books/0')->status_is(302);
|
$t->get_ok('/0')->status_is(302);
|
||||||
|
|
||||||
# Now follow redirects and verify it's a 404.
|
# Now follow redirects and verify it's a 404.
|
||||||
$t->ua->max_redirects(10);
|
$t->ua->max_redirects(10);
|
||||||
$t->get_ok('/books/0')->status_is(404);
|
$t->get_ok('/0')->status_is(404);
|
||||||
|
|
||||||
# Likewise for a too-high page number.
|
# A too-high page number should take us to the last page.
|
||||||
$t->get_ok('/books/999?title_like=qxqxqxqx')->status_is(404);
|
$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.
|
# Likewise for invalid page numbers.
|
||||||
$t->get_ok('/books/x')->status_is(404);
|
$t->get_ok('/x')->status_is(404);
|
||||||
$t->get_ok('/books/1.99')->status_is(404);
|
$t->get_ok('/1.99')->status_is(404);
|
||||||
$t->get_ok('/books/-42')->status_is(404);
|
$t->get_ok('/-42')->status_is(404);
|
||||||
|
|
||||||
# Or non-existent author.
|
# Or non-existent author.
|
||||||
$t->get_ok('/author/0/1')->status_is(404);
|
$t->get_ok('/author/0/1')->status_is(404);
|
||||||
|
|
Loading…
Reference in New Issue