Tests: Add test cases for option --start-pos.
authorYousong Zhou <yszhou4tech@gmail.com>
Wed, 19 Mar 2014 15:42:07 +0000 (23:42 +0800)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Fri, 21 Mar 2014 10:21:10 +0000 (11:21 +0100)
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
tests/ChangeLog
tests/Test--start-pos--continue.px [new file with mode: 0755]
tests/Test--start-pos.px [new file with mode: 0755]
tests/Test-ftp--start-pos.px [new file with mode: 0755]
tests/run-px

index d23e76e45b92a6a3ccf9e2e0f4b72c679836d3c5..f2e80e527b4a315652c009c920cb975820b6535e 100644 (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
diff --git a/tests/Test--start-pos--continue.px b/tests/Test--start-pos--continue.px
new file mode 100755 (executable)
index 0000000..09b8ced
--- /dev/null
@@ -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 (executable)
index 0000000..4962c82
--- /dev/null
@@ -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 (executable)
index 0000000..5062377
--- /dev/null
@@ -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
+
+
+
index a3f61bb8f9802c5291d2e6e357a743bb7bbdbf67..402f22929d93340db17f6f2c792f488be744c814 100755 (executable)
@@ -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)) {