1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Tests: Add test cases for option --start-pos.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
This commit is contained in:
Yousong Zhou 2014-03-19 23:42:07 +08:00 committed by Giuseppe Scrivano
parent ed54c64ad2
commit c9bc854938
5 changed files with 155 additions and 0 deletions

View File

@ -1,3 +1,10 @@
2014-02-13 Yousong Zhou <yszhou4tech@gmail.com>
* Test--start-pos.px: Test --start-pos for HTTP downloads.
* Test-ftp--start-pos.px: Test --start-pos for FTP downloads.
* Test--start-pos--continue.px: Test the case when --start-pos and
--continue were both specified.
2014-02-13 Yousong Zhou <yszhou4tech@gmail.com>
* Wget.pm.in: Exclude existing files from the check of unexpected

View File

@ -0,0 +1,57 @@
#!/usr/bin/env perl
use strict;
use warnings;
use HTTPTest;
###############################################################################
my $existingfile = <<EOF;
content should be preserved.
EOF
my $wholefile = "1234";
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "206",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = $WgetTest::WGETPATH . " --start-pos=1 --continue --debug http://localhost:{{port}}/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
'somefile.txt' => {
content => $existingfile,
},
);
my %expected_downloaded_files = (
'somefile.txt.1' => {
content => substr($wholefile, 1),
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test--start-pos--continue",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
exit $the_test->run();
# vim: et ts=4 sw=4

46
tests/Test--start-pos.px Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env perl
use strict;
use warnings;
use HTTPTest;
###############################################################################
my $dummyfile = "1234";
# code, msg, headers, content
my %urls = (
'/dummy.txt' => {
code => "206",
msg => "Dontcare",
headers => {
"Content-Type" => "text/plain",
},
content => $dummyfile
},
);
my $cmdline = $WgetTest::WGETPATH . " --start-pos=1 http://localhost:{{port}}/dummy.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'dummy.txt' => {
content => substr($dummyfile, 1),
}
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test--start-pos",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
exit $the_test->run();
# vim: et ts=4 sw=4

42
tests/Test-ftp--start-pos.px Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FTPTest;
###############################################################################
my $dummyfile = "1234";
# code, msg, headers, content
my %urls = (
'/dummy.txt' => {
content => $dummyfile
},
);
my $cmdline = $WgetTest::WGETPATH . " --start-pos=1 ftp://localhost:{{port}}/dummy.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'dummy.txt' => {
content => substr($dummyfile, 1),
}
);
###############################################################################
my $the_test = FTPTest->new (name => "Test-ftp--start-pos",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
exit $the_test->run();
# vim: et ts=4 sw=4

View File

@ -88,6 +88,9 @@ my @tests = (
'Test--spider-r--no-content-disposition-trivial.px',
'Test--spider-r.px',
'Test--httpsonly-r.px',
'Test--start-pos.px',
'Test-ftp--start-pos.px',
'Test--start-pos--continue.px',
);
foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {