bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-wget] [PATCH v5 4/4] Tests: Add test cases for option --start-pos.


From: Yousong Zhou
Subject: [Bug-wget] [PATCH v5 4/4] Tests: Add test cases for option --start-pos.
Date: Fri, 14 Feb 2014 10:06:49 +0800

Signed-off-by: Yousong Zhou <address@hidden>
---
 tests/ChangeLog                    |    7 ++++
 tests/Test--start-pos--continue.px |   57 ++++++++++++++++++++++++++++++++++++
 tests/Test--start-pos.px           |   46 +++++++++++++++++++++++++++++
 tests/Test-ftp--start-pos.px       |   42 ++++++++++++++++++++++++++
 tests/run-px                       |    3 ++
 5 files changed, 155 insertions(+), 0 deletions(-)
 create mode 100755 tests/Test--start-pos--continue.px
 create mode 100755 tests/Test--start-pos.px
 create mode 100755 tests/Test-ftp--start-pos.px

diff --git a/tests/ChangeLog b/tests/ChangeLog
index d23e76e..f2e80e5 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,12 @@
 2014-02-13  Yousong Zhou  <address@hidden>
 
+       * 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  <address@hidden>
+
        * Wget.pm.in: Exclude existing files from the check of unexpected
          downloads.
 
diff --git a/tests/Test--start-pos--continue.px 
b/tests/Test--start-pos--continue.px
new file mode 100755
index 0000000..09b8ced
--- /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 = <<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
+
+
diff --git a/tests/Test--start-pos.px b/tests/Test--start-pos.px
new file mode 100755
index 0000000..4962c82
--- /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 0000000..5062377
--- /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 a3f61bb..402f229 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)) {
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]