comparison autoindex.t @ 108:93a8f4202b16

Tests: add autoindex module tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 14 Oct 2009 03:16:19 +0400
parents
children 51f3c88b2930
comparison
equal deleted inserted replaced
107:1c0ec30614c6 108:93a8f4202b16
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for autoindex module.
6
7 ###############################################################################
8
9 use warnings;
10 use strict;
11
12 use Test::More;
13
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
15
16 use lib 'lib';
17 use Test::Nginx;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->plan(4)
25 ->write_file_expand('nginx.conf', <<'EOF');
26
27 %%TEST_GLOBALS%%
28
29 master_process off;
30 daemon off;
31
32 events {
33 }
34
35 http {
36 %%TEST_GLOBALS_HTTP%%
37
38 server {
39 listen 127.0.0.1:8080;
40 server_name localhost;
41
42 location / {
43 autoindex on;
44 }
45 }
46 }
47
48 EOF
49
50 my $d = $t->testdir();
51
52 mkdir("$d/test-dir");
53 symlink("$d/test-dir", "$d/test-dir-link");
54
55 $t->write_file('test-file', '');
56 symlink("$d/test-file", "$d/test-file-link");
57
58 $t->run();
59
60 ###############################################################################
61
62 my $r = http_get('/');
63
64 like($r, qr!href="test-file"!ms, 'file');
65 like($r, qr!href="test-file-link"!ms, 'symlink to file');
66 like($r, qr!href="test-dir/"!ms, 'directory');
67
68 TODO: {
69 local $TODO = 'patch under review';
70
71 like($r, qr!href="test-dir-link/"!ms, 'symlink to directory');
72
73 }
74
75 ###############################################################################