-
Notifications
You must be signed in to change notification settings - Fork 234
/
Copy pathstatic-mounts.t
106 lines (103 loc) · 3.71 KB
/
static-mounts.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use strict;
use warnings;
use lib 't/lib';
use MetaCPAN::Web::Test qw( app GET test_psgi );
use Test::More;
test_psgi app, sub {
my $cb = shift;
{
ok( my $res = $cb->( GET '/favicon.ico' ), 'GET /favicon.ico' );
is( $res->code, 200, 'code 200' );
unlike $res->header('Cache-Control'), qr/immutable/, "not immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=image
content_type=image/vnd.microsoft.icon
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/static/opensearch.xml' ),
'GET /static/opensearch.xml' );
is( $res->code, 200, 'code 200' );
unlike $res->header('Cache-Control'), qr/immutable/, "not immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=application
content_type=application/xml
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/static/fastly_do_not_delete.gif' ),
'GET /static/fastly_do_not_delete.gif' );
is( $res->code, 200, 'code 200' );
unlike $res->header('Cache-Control'), qr/immutable/, "not immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=image
content_type=image/gif
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/static/icons/grid.svg' ),
'GET /static/icons/grid.svg' );
is( $res->code, 200, 'code 200' );
like $res->header('Cache-Control'), qr/immutable/, "immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=image
content_type=image/svg+xml
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/static/images/dots.svg' ),
'GET /static/images/dots.svg' );
is( $res->code, 200, 'code 200' );
like $res->header('Cache-Control'), qr/immutable/, "immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=image
content_type=image/svg+xml
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/static/js/main.mjs' ),
'GET /static/js/main.mjs' );
is( $res->code, 200, 'code 200' );
unlike $res->header('Cache-Control'), qr/immutable/, "not immutable";
is_deeply [ sort split /,? /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=application
content_type=application/javascript
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/assets/assets.json' ),
'GET /assets/assets.json' );
is( $res->code, 200, 'code 200' );
like $res->header('Cache-Control'), qr/immutable/, "immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
assets
content_type=application
content_type=application/json
) ],
'correct Surrogate-Key';
}
{
ok( my $res = $cb->( GET '/assets/this-file-does-not-exist.js' ),
'GET /assets/this-file-does-not-exist.js' );
is( $res->code, 404, 'code 404' );
unlike $res->header('Cache-Control'), qr/immutable/, "not immutable";
is_deeply [ sort split /, /, $res->header('Surrogate-Key') ], [ qw(
content_type=text
content_type=text/plain
) ],
'correct Surrogate-Key';
}
};
done_testing;