summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/50-comirror.t46
-rwxr-xr-xtest/60-comirror-setup.t45
-rw-r--r--test/next-loop/1.jpg0
-rw-r--r--test/next-loop/1.xhtml14
-rw-r--r--test/next-loop/2.jpg0
-rw-r--r--test/next-loop/2.xhtml14
-rw-r--r--test/next-loop/3.jpg0
-rw-r--r--test/next-loop/3.xhtml14
-rw-r--r--test/next-loop/4.jpg0
-rw-r--r--test/next-loop/4.xhtml14
-rw-r--r--test/next-loop/5.jpg0
-rw-r--r--test/next-loop/5.xhtml14
-rw-r--r--test/next-none/1.jpg0
-rw-r--r--test/next-none/1.xhtml14
-rw-r--r--test/next-none/2.jpg0
-rw-r--r--test/next-none/2.xhtml14
-rw-r--r--test/next-none/3.jpg0
-rw-r--r--test/next-none/3.xhtml14
-rw-r--r--test/next-none/4.jpg0
-rw-r--r--test/next-none/4.xhtml14
-rw-r--r--test/next-none/5.jpg0
-rw-r--r--test/next-none/5.xhtml13
22 files changed, 230 insertions, 0 deletions
diff --git a/test/50-comirror.t b/test/50-comirror.t
new file mode 100755
index 0000000..3dc25b7
--- /dev/null
+++ b/test/50-comirror.t
@@ -0,0 +1,46 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+use Cwd;
+use Test::More tests => 26;
+use Test::Cmd;
+
+for my $next_type (qw/ loop none /) {
+
+ my $test = Test::Cmd->new( prog => 'bin/comirror', workdir => q{} );
+ my $cwd = $test->workdir();
+
+ my $next_base = 'file://' . getcwd() . "/test/next-${next_type}";
+ my ($str, $exit);
+
+ ok($test, "Create Test::Cmd object ($next_type)");
+
+ $test->write('image_re', "${next_base}/.+");
+ $exit = $test->run(
+ chdir => $cwd,
+ args => "${next_base}/1.xhtml",
+ );
+
+ ok($exit == 0, 'First run: return 0');
+
+ isnt($test->stdout, q{}, 'First run: Non-empty stdout');
+ is ($test->stderr, q{}, 'First run: Empty stderr');
+
+ $test->read(\$str, 'last_uri');
+ is($str, "${next_base}/4.xhtml", "Correct last_uri ($next_type)");
+
+ for my $i (1 .. 5) {
+ ok(-e "$cwd/$i.jpg",
+ "$i.jpg was downloaded successfully ($next_type)");
+ }
+
+ $exit = $test->run(
+ chdir => $cwd,
+ );
+
+ ok(($exit >> 8) == 1, 'Second run: return 1 (no new images loaded)');
+
+ isnt($test->stdout, q{}, 'Second run: Non-empty stdout');
+ is ($test->stderr, q{}, 'Second run: Empty stderr');
+}
diff --git a/test/60-comirror-setup.t b/test/60-comirror-setup.t
new file mode 100755
index 0000000..5f61969
--- /dev/null
+++ b/test/60-comirror-setup.t
@@ -0,0 +1,45 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+use Cwd;
+use Test::More tests => 9;
+use Test::Cmd;
+
+my $test = Test::Cmd->new( prog => 'bin/comirror-setup', workdir => q{} );
+my $cwd = $test->workdir();
+
+my $next_base = 'file://' . getcwd() . '/test/next-loop';
+my ($str, $exit);
+my @links;
+
+ok($test, 'Create Test::Cmd object');
+
+$exit = $test->run(
+ chdir => $cwd
+);
+
+ok($exit != 0, 'Not enough arguments: non-zero return');
+
+is ($test->stdout, q{}, 'Not enough arguments: Nothing to stdout');
+isnt($test->stderr, q{}, 'Not enough arguments: Something to stderr');
+
+for my $i (1 .. 5) {
+ push(@links, "${next_base}/${i}.xhtml");
+}
+
+$exit = $test->run(
+ chdir => $cwd,
+ args => join(q{ }, @links[0, 1, 3]),
+);
+
+ok($exit == 0, 'Correct usage: return zero');
+
+isnt($test->stdout, q{}, 'Correct usage: Something to stdout');
+is ($test->stderr, q{}, 'Correct usage: Nothing to stderr');
+
+$test->read(\$str, 'last_uri');
+is($str, "$links[0]\n", 'Correct last_uri');
+
+$test->read(\$str, 'image_re');
+is($str, "${next_base}/.+\n", 'Correct image_re');
diff --git a/test/next-loop/1.jpg b/test/next-loop/1.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-loop/1.jpg
diff --git a/test/next-loop/1.xhtml b/test/next-loop/1.xhtml
new file mode 100644
index 0000000..c0efc65
--- /dev/null
+++ b/test/next-loop/1.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="1.jpg"/>
+ <a href="2.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-loop/2.jpg b/test/next-loop/2.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-loop/2.jpg
diff --git a/test/next-loop/2.xhtml b/test/next-loop/2.xhtml
new file mode 100644
index 0000000..60e57e1
--- /dev/null
+++ b/test/next-loop/2.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="2.jpg"/>
+ <a href="3.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-loop/3.jpg b/test/next-loop/3.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-loop/3.jpg
diff --git a/test/next-loop/3.xhtml b/test/next-loop/3.xhtml
new file mode 100644
index 0000000..97eadf4
--- /dev/null
+++ b/test/next-loop/3.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="3.jpg"/>
+ <a href="4.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-loop/4.jpg b/test/next-loop/4.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-loop/4.jpg
diff --git a/test/next-loop/4.xhtml b/test/next-loop/4.xhtml
new file mode 100644
index 0000000..b0cf520
--- /dev/null
+++ b/test/next-loop/4.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="4.jpg"/>
+ <a href="5.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-loop/5.jpg b/test/next-loop/5.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-loop/5.jpg
diff --git a/test/next-loop/5.xhtml b/test/next-loop/5.xhtml
new file mode 100644
index 0000000..86ff9e8
--- /dev/null
+++ b/test/next-loop/5.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="5.jpg"/>
+ <a href="5.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-none/1.jpg b/test/next-none/1.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-none/1.jpg
diff --git a/test/next-none/1.xhtml b/test/next-none/1.xhtml
new file mode 100644
index 0000000..c0efc65
--- /dev/null
+++ b/test/next-none/1.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="1.jpg"/>
+ <a href="2.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-none/2.jpg b/test/next-none/2.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-none/2.jpg
diff --git a/test/next-none/2.xhtml b/test/next-none/2.xhtml
new file mode 100644
index 0000000..60e57e1
--- /dev/null
+++ b/test/next-none/2.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="2.jpg"/>
+ <a href="3.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-none/3.jpg b/test/next-none/3.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-none/3.jpg
diff --git a/test/next-none/3.xhtml b/test/next-none/3.xhtml
new file mode 100644
index 0000000..97eadf4
--- /dev/null
+++ b/test/next-none/3.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="3.jpg"/>
+ <a href="4.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-none/4.jpg b/test/next-none/4.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-none/4.jpg
diff --git a/test/next-none/4.xhtml b/test/next-none/4.xhtml
new file mode 100644
index 0000000..b0cf520
--- /dev/null
+++ b/test/next-none/4.xhtml
@@ -0,0 +1,14 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="4.jpg"/>
+ <a href="5.xhtml">Next =></a>
+</div>
+</body>
+</html>
diff --git a/test/next-none/5.jpg b/test/next-none/5.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/next-none/5.jpg
diff --git a/test/next-none/5.xhtml b/test/next-none/5.xhtml
new file mode 100644
index 0000000..41012d9
--- /dev/null
+++ b/test/next-none/5.xhtml
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+<div>
+ <img src="5.jpg"/>
+</div>
+</body>
+</html>