Debian Codegraph @

tests/Test--spider-r.px

raw
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 use HTTPTest;
7
8
9 ###############################################################################
10
11 my $mainpage = <<EOF;
12 <html>
13 <head>
14 <title>Main Page</title>
15 </head>
16 <body>
17 <p>
18 Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
19 Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
20 </p>
21 </body>
22 </html>
23 EOF
24
25 my $secondpage = <<EOF;
26 <html>
27 <head>
28 <title>Second Page</title>
29 </head>
30 <body>
31 <p>
32 Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
33 Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
34 </p>
35 </body>
36 </html>
37 EOF
38
39 my $thirdpage = <<EOF;
40 <html>
41 <head>
42 <title>Third Page</title>
43 </head>
44 <body>
45 <p>
46 Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
47 Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
48 </p>
49 </body>
50 </html>
51 EOF
52
53 my $dummyfile = <<EOF;
54 Don't care.
55 EOF
56
57 # code, msg, headers, content
58 my %urls = (
59 '/index.html' => {
60 code => "200",
61 msg => "Dontcare",
62 headers => {
63 "Content-type" => "text/html",
64 },
65 content => $mainpage,
66 },
67 '/secondpage.html' => {
68 code => "200",
69 msg => "Dontcare",
70 headers => {
71 "Content-type" => "text/html",
72 },
73 content => $secondpage,
74 },
75 '/thirdpage.html' => {
76 code => "200",
77 msg => "Dontcare",
78 headers => {
79 "Content-type" => "text/html",
80 },
81 content => $thirdpage,
82 },
83 '/dummy.txt' => {
84 code => "200",
85 msg => "Dontcare",
86 headers => {
87 "Content-type" => "text/plain",
88 },
89 content => $dummyfile
90 },
91 );
92
93 my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/";
94
95 my $expected_error_code = 8;
96
97 my %expected_downloaded_files = (
98 );
99
100 ###############################################################################
101
102 my $the_test = HTTPTest->new (input => \%urls,
103 cmdline => $cmdline,
104 errcode => $expected_error_code,
105 output => \%expected_downloaded_files);
106 exit $the_test->run();
107
108 # vim: et ts=4 sw=4