From: Yousong Zhou Date: Wed, 19 Mar 2014 15:42:07 +0000 (+0800) Subject: Tests: Add test cases for option --start-pos. X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=c9bc854938346430749285c95ba42d552d68d048 Tests: Add test cases for option --start-pos. Signed-off-by: Yousong Zhou --- diff --git a/tests/ChangeLog b/tests/ChangeLog index d23e76e4..f2e80e52 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2014-02-13 Yousong Zhou + + * 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 * Wget.pm.in: Exclude existing files from the check of unexpected diff --git a/tests/Test--start-pos--continue.px b/tests/Test--start-pos--continue.px new file mode 100755 index 00000000..09b8ced2 --- /dev/null +++ b/tests/Test--start-pos--continue.px @@ -0,0 +1,57 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use HTTPTest; + + +############################################################################### + +my $existingfile = < { + 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 + + diff --git a/tests/Test--start-pos.px b/tests/Test--start-pos.px new file mode 100755 index 00000000..4962c820 --- /dev/null +++ b/tests/Test--start-pos.px @@ -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 + + diff --git a/tests/Test-ftp--start-pos.px b/tests/Test-ftp--start-pos.px new file mode 100755 index 00000000..50623771 --- /dev/null +++ b/tests/Test-ftp--start-pos.px @@ -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 + + + diff --git a/tests/run-px b/tests/run-px index a3f61bb8..402f2292 100755 --- a/tests/run-px +++ b/tests/run-px @@ -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)) {