Add plugin_dir and plugin_list test cases.
authorGavin Carr <gonzai@users.sourceforge.net>
Wed, 3 Oct 2007 11:58:13 +0000 (11:58 +0000)
committerGavin Carr <gonzai@users.sourceforge.net>
Wed, 3 Oct 2007 11:58:13 +0000 (11:58 +0000)
28 files changed:
t/04_plugin_dir.t [new file with mode: 0644]
t/05_plugin_list.t [new file with mode: 0644]
t/plugin_dir/config/blosxom.conf [new file with mode: 0644]
t/plugin_dir/data/1.txt [new file with mode: 0644]
t/plugin_dir/data/date.html [new file with mode: 0644]
t/plugin_dir/data/foot.html [new file with mode: 0644]
t/plugin_dir/data/head.html [new file with mode: 0644]
t/plugin_dir/data/story.html [new file with mode: 0644]
t/plugin_dir/expected.html [new file with mode: 0644]
t/plugin_dir/plugins/02plugin2 [new file with mode: 0644]
t/plugin_dir/plugins/04plugin4_ [new file with mode: 0644]
t/plugin_dir/plugins/dump_plugins [new file with mode: 0644]
t/plugin_dir/plugins/plugin1 [new file with mode: 0644]
t/plugin_dir/plugins/plugin3_ [new file with mode: 0644]
t/plugin_list/config/blosxom.conf [new file with mode: 0644]
t/plugin_list/config/plugins.conf [new file with mode: 0644]
t/plugin_list/data/1.txt [new file with mode: 0644]
t/plugin_list/data/date.html [new file with mode: 0644]
t/plugin_list/data/foot.html [new file with mode: 0644]
t/plugin_list/data/head.html [new file with mode: 0644]
t/plugin_list/data/story.html [new file with mode: 0644]
t/plugin_list/expected.html [new file with mode: 0644]
t/plugin_list/plugins/dump_plugins [new file with mode: 0644]
t/plugin_list/plugins/plugin1 [new file with mode: 0644]
t/plugin_list/plugins/plugin2 [new file with mode: 0644]
t/plugin_list/plugins/plugin3 [new file with mode: 0644]
t/plugin_list/plugins/plugin4 [new file with mode: 0644]
t/plugin_list/plugins/plugin5 [new file with mode: 0644]

diff --git a/t/04_plugin_dir.t b/t/04_plugin_dir.t
new file mode 100644 (file)
index 0000000..c27c35b
--- /dev/null
@@ -0,0 +1,35 @@
+# blosxom standard $plugin_dir testing
+
+use strict;
+use Test::More tests => 1;
+use Test::Differences;
+use Cwd;
+use IO::File;
+
+my $blosxom_root = 'plugin_dir';
+$blosxom_root = "t/$blosxom_root" if -d "t/$blosxom_root";
+$blosxom_root = cwd . "/$blosxom_root";
+die "cannot find root '$blosxom_root'" 
+  unless -d $blosxom_root;
+
+my $blosxom_config_dir = "$blosxom_root/config";
+die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_config_dir;
+$ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir;
+
+my $blosxom_cgi = "$blosxom_root/../../blosxom.cgi";
+die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi;
+die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi;
+
+my $fh = IO::File->new("$blosxom_root/expected.html", 'r')
+  or die "cannot open expected output file '$blosxom_root/expected.html': $!";
+my $expected;
+{
+  local $/ = undef;
+  $expected = <$fh>;
+  $fh->close;
+}
+
+my $output = qx($blosxom_cgi);
+
+eq_or_diff($output, $expected, 'html output ok');
+
diff --git a/t/05_plugin_list.t b/t/05_plugin_list.t
new file mode 100644 (file)
index 0000000..5e4e952
--- /dev/null
@@ -0,0 +1,35 @@
+# blosxom $plugin_list testing
+
+use strict;
+use Test::More tests => 1;
+use Test::Differences;
+use Cwd;
+use IO::File;
+
+my $blosxom_root = 'plugin_list';
+$blosxom_root = "t/$blosxom_root" if -d "t/$blosxom_root";
+$blosxom_root = cwd . "/$blosxom_root";
+die "cannot find root '$blosxom_root'" 
+  unless -d $blosxom_root;
+
+my $blosxom_config_dir = "$blosxom_root/config";
+die "cannot find blosxom config dir '$blosxom_config_dir'" unless -d $blosxom_config_dir;
+$ENV{BLOSXOM_CONFIG_DIR} = $blosxom_config_dir;
+
+my $blosxom_cgi = "$blosxom_root/../../blosxom.cgi";
+die "cannot find blosxom.cgi '$blosxom_cgi'" unless -f $blosxom_cgi;
+die "blosxom.cgi '$blosxom_cgi' is not executable" unless -x $blosxom_cgi;
+
+my $fh = IO::File->new("$blosxom_root/expected.html", 'r')
+  or die "cannot open expected output file '$blosxom_root/expected.html': $!";
+my $expected;
+{
+  local $/ = undef;
+  $expected = <$fh>;
+  $fh->close;
+}
+
+my $output = qx($blosxom_cgi);
+
+eq_or_diff($output, $expected, 'html output ok');
+
diff --git a/t/plugin_dir/config/blosxom.conf b/t/plugin_dir/config/blosxom.conf
new file mode 100644 (file)
index 0000000..679a892
--- /dev/null
@@ -0,0 +1,5 @@
+$blog_title = 'plugin_list test';
+$blog_encoding = 'ISO-8859-1';
+$datadir = "$ENV{BLOSXOM_CONFIG_DIR}/../data";
+$plugin_list = '';
+$plugin_dir  = "$ENV{BLOSXOM_CONFIG_DIR}/../plugins";
diff --git a/t/plugin_dir/data/1.txt b/t/plugin_dir/data/1.txt
new file mode 100644 (file)
index 0000000..748c525
--- /dev/null
@@ -0,0 +1,4 @@
+Story 1
+
+Story 1 text
+
diff --git a/t/plugin_dir/data/date.html b/t/plugin_dir/data/date.html
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/t/plugin_dir/data/foot.html b/t/plugin_dir/data/foot.html
new file mode 100644 (file)
index 0000000..308b1d0
--- /dev/null
@@ -0,0 +1,2 @@
+</body>
+</html>
diff --git a/t/plugin_dir/data/head.html b/t/plugin_dir/data/head.html
new file mode 100644 (file)
index 0000000..f70f5a3
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title>$blog_title</title>
+</head>
+<body>
+<h1>$blog_title</h1>
diff --git a/t/plugin_dir/data/story.html b/t/plugin_dir/data/story.html
new file mode 100644 (file)
index 0000000..ca627b8
--- /dev/null
@@ -0,0 +1,2 @@
+$dump_plugins::list
+$body
diff --git a/t/plugin_dir/expected.html b/t/plugin_dir/expected.html
new file mode 100644 (file)
index 0000000..4c5f854
--- /dev/null
@@ -0,0 +1,22 @@
+Content-Type: text/html; charset=ISO-8859-1\r
+\r
+<html>
+<head>
+<title>plugin_list test</title>
+</head>
+<body>
+<h1>plugin_list test</h1>
+
+<pre>
+plugin2
+plugin4
+dump_plugins
+plugin1
+plugin3
+</pre>
+
+
+Story 1 text
+
+</body>
+</html>
diff --git a/t/plugin_dir/plugins/02plugin2 b/t/plugin_dir/plugins/02plugin2
new file mode 100644 (file)
index 0000000..1c86931
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin2;
+sub start { 1 };
+1;
diff --git a/t/plugin_dir/plugins/04plugin4_ b/t/plugin_dir/plugins/04plugin4_
new file mode 100644 (file)
index 0000000..2ddb545
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin4;
+sub start { 1 };
+1;
diff --git a/t/plugin_dir/plugins/dump_plugins b/t/plugin_dir/plugins/dump_plugins
new file mode 100644 (file)
index 0000000..3550b4b
--- /dev/null
@@ -0,0 +1,5 @@
+package dump_plugins;
+use vars qw($list);
+sub start { 1 };
+sub head { $list = sprintf "<pre>\n%s\n</pre>\n", join("\n", @blosxom::plugins); }
+1;
diff --git a/t/plugin_dir/plugins/plugin1 b/t/plugin_dir/plugins/plugin1
new file mode 100644 (file)
index 0000000..635cd26
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin1;
+sub start { 1 };
+1;
diff --git a/t/plugin_dir/plugins/plugin3_ b/t/plugin_dir/plugins/plugin3_
new file mode 100644 (file)
index 0000000..e2d75ce
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin3;
+sub start { 1 };
+1;
diff --git a/t/plugin_list/config/blosxom.conf b/t/plugin_list/config/blosxom.conf
new file mode 100644 (file)
index 0000000..859eb10
--- /dev/null
@@ -0,0 +1,5 @@
+$blog_title = 'plugin_list test';
+$blog_encoding = 'ISO-8859-1';
+$datadir = "$ENV{BLOSXOM_CONFIG_DIR}/../data";
+$plugin_list = "$ENV{BLOSXOM_CONFIG_DIR}/plugins.conf";
+$plugin_dir  = "$ENV{BLOSXOM_CONFIG_DIR}/../plugins";
diff --git a/t/plugin_list/config/plugins.conf b/t/plugin_list/config/plugins.conf
new file mode 100644 (file)
index 0000000..3a4090e
--- /dev/null
@@ -0,0 +1,19 @@
+
+# Bare
+plugin1
+
+# Numbered
+02plugin2
+
+# Underscored
+plugin3_
+
+# Numbered and underscored
+04plugin4_
+
+# Commented out
+# plugin5
+
+# Real plugin - dump the list of plugins
+dump_plugins
+
diff --git a/t/plugin_list/data/1.txt b/t/plugin_list/data/1.txt
new file mode 100644 (file)
index 0000000..748c525
--- /dev/null
@@ -0,0 +1,4 @@
+Story 1
+
+Story 1 text
+
diff --git a/t/plugin_list/data/date.html b/t/plugin_list/data/date.html
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/t/plugin_list/data/foot.html b/t/plugin_list/data/foot.html
new file mode 100644 (file)
index 0000000..308b1d0
--- /dev/null
@@ -0,0 +1,2 @@
+</body>
+</html>
diff --git a/t/plugin_list/data/head.html b/t/plugin_list/data/head.html
new file mode 100644 (file)
index 0000000..f70f5a3
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head>
+<title>$blog_title</title>
+</head>
+<body>
+<h1>$blog_title</h1>
diff --git a/t/plugin_list/data/story.html b/t/plugin_list/data/story.html
new file mode 100644 (file)
index 0000000..ca627b8
--- /dev/null
@@ -0,0 +1,2 @@
+$dump_plugins::list
+$body
diff --git a/t/plugin_list/expected.html b/t/plugin_list/expected.html
new file mode 100644 (file)
index 0000000..14603c8
--- /dev/null
@@ -0,0 +1,22 @@
+Content-Type: text/html; charset=ISO-8859-1\r
+\r
+<html>
+<head>
+<title>plugin_list test</title>
+</head>
+<body>
+<h1>plugin_list test</h1>
+
+<pre>
+plugin1
+plugin2
+plugin3
+plugin4
+dump_plugins
+</pre>
+
+
+Story 1 text
+
+</body>
+</html>
diff --git a/t/plugin_list/plugins/dump_plugins b/t/plugin_list/plugins/dump_plugins
new file mode 100644 (file)
index 0000000..3550b4b
--- /dev/null
@@ -0,0 +1,5 @@
+package dump_plugins;
+use vars qw($list);
+sub start { 1 };
+sub head { $list = sprintf "<pre>\n%s\n</pre>\n", join("\n", @blosxom::plugins); }
+1;
diff --git a/t/plugin_list/plugins/plugin1 b/t/plugin_list/plugins/plugin1
new file mode 100644 (file)
index 0000000..635cd26
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin1;
+sub start { 1 };
+1;
diff --git a/t/plugin_list/plugins/plugin2 b/t/plugin_list/plugins/plugin2
new file mode 100644 (file)
index 0000000..1c86931
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin2;
+sub start { 1 };
+1;
diff --git a/t/plugin_list/plugins/plugin3 b/t/plugin_list/plugins/plugin3
new file mode 100644 (file)
index 0000000..e2d75ce
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin3;
+sub start { 1 };
+1;
diff --git a/t/plugin_list/plugins/plugin4 b/t/plugin_list/plugins/plugin4
new file mode 100644 (file)
index 0000000..2ddb545
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin4;
+sub start { 1 };
+1;
diff --git a/t/plugin_list/plugins/plugin5 b/t/plugin_list/plugins/plugin5
new file mode 100644 (file)
index 0000000..17a57bc
--- /dev/null
@@ -0,0 +1,3 @@
+package plugin5;
+sub start { 1 };
+1;