Skip to content

Commit 0210525

Browse files
committed
tests: Hash randomization can cause .pl MIME to vary
Since Perl 5.18, MIME::Types has started to vary the reported MIME type for perl scripts. It can be either application/perl or text/perl. This change will make sure that the test verifies that the content-type is the same as MIME::Types reports for .pl, without having to know which one it is.
1 parent 62b99ff commit 0210525

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

t/06_helpers/01_send_file.t

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use Dancer ':syntax';
66
use Dancer::FileUtils 'read_glob_content';
77
use Dancer::Test;
88
use File::Temp;
9+
use MIME::Types;
910

1011
set public => path(dirname(__FILE__), 'public');
1112

@@ -86,7 +87,12 @@ $resp = undef; # just to be sure
8687
$resp = dancer_response(GET => '/absolute/file.txt');
8788
ok(defined($resp), "route handler found for /absolute/file.txt");
8889
%headers = @{$resp->headers_to_array};
89-
is($headers{'Content-Type'}, 'application/x-perl', 'mime_type is ok');
90+
91+
# With hash randomization, .pl can be either text/perl or
92+
# application/perl. This is determined by MIME::Types.
93+
my $perl_mime = MIME::Types->new->mimeTypeOf('pl');
94+
is($headers{'Content-Type'}, $perl_mime, 'mime_type is ok');
95+
9096
is(ref($resp->{content}), 'GLOB', "content is a File handle");
9197
$content = read_glob_content($resp->{content});
9298
like($content, qr/'foo loaded'/, "content is ok");

0 commit comments

Comments
 (0)