- Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathnot_found.t
43 lines (35 loc) · 1.24 KB
/
not_found.t
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
use strict;
use warnings;
use lib 't/lib';
use MetaCPAN::Server::Test qw( app GET test_psgi );
use MetaCPAN::TestHelpers qw( decode_json_ok );
use Test::More;
my@tests = (
[ '/changes/LOCAL/File-Changes-2'=> 404 ],
[ '/changes/LOCAL/File-Changes-2.0'=> 200 ],
[ '/fakedoctype/andaction'=> 404 ],
[ '/file/LOCAL/File-Changes-2.0/Changes'=> 200 ],
[ '/file/LOCAL/File-Changes-2.0/NoChanges'=> 404 ],
[ '/release/File-Changes'=> 200 ],
[ '/release/No-Dist-Here'=> 404 ],
[ '/root.file'=> 404 ],
);
test_psgi app, sub {
my$cb = shift;
formy$test (@tests) {
my ( $path, $code ) = @{$test};
ok( my$res = $cb->( GET $path ), "GET $path" );
is( $res->code, $code, "code $code" );
# 404 should still be json
is(
$res->header('content-type'),
'application/json; charset=utf-8',
'Content-type'
);
my$json = decode_json_ok($res);
nextunless$res->code == 404;
is( $json->{message}, 'Not found', '404 message as expected' );
is( $json->{code}, $code, 'code as expected' );
}
};
done_testing;