blob: d73f691a72f1e62ba624bafaa9e81ba4a6147df9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Plack::Test;
use HTTP::Request::Common;
use Plack::Builder;
my $app = builder {
enable "Xslate",
path => qr{^/}, root => 't/basic/', pass_through => 1;
sub { [ 404, [], [ 'Not found' ] ] };
};
test_psgi
app => $app,
client => sub {
my $cb = shift;
{
my $res = $cb->(GET '/index.html');
ok($res->is_success) || diag($res->content);
my $rendered = <<'CONTENT';
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/style.css" />
</head>
<body>
<h1>Hello world</h1>
</body>
</html>
CONTENT
is($res->content, $rendered);
is($res->header('Content-Length'), length($rendered));
}
{
my $res = $cb->(GET '/missing.html');
is($res->code, 404);
}
};
done_testing;
|