aboutsummaryrefslogtreecommitdiff
path: root/t/cvs.t
diff options
context:
space:
mode:
authorAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2012-01-21 20:17:52 -0500
committerAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2012-01-22 10:44:49 -0500
commitd760df3821d67b97561e7868b3ce52b1a66e9b13 (patch)
treefdc9c5ca52e6dc1ae50cb50a3057b895c9cf8bf5 /t/cvs.t
parentb77da0bb3b52ee51e652515e69fc0d986581fd1e (diff)
downloadikiwiki-d760df3821d67b97561e7868b3ce52b1a66e9b13.tar
ikiwiki-d760df3821d67b97561e7868b3ce52b1a66e9b13.tar.gz
* Define expected number of tests near the top.
* Call readfile() directly from writefile(). * Parameterize commit message for the web-commit case. * Describe intent of test cases. * Rename test subs to match what they actually do. * To prove extra path slashes don't cause trouble, instead of running the same tests a second time, just assert that checkconfig() strips the slashes.
Diffstat (limited to 't/cvs.t')
-rwxr-xr-xt/cvs.t81
1 files changed, 55 insertions, 26 deletions
diff --git a/t/cvs.t b/t/cvs.t
index c4e9eb276..af1786c65 100755
--- a/t/cvs.t
+++ b/t/cvs.t
@@ -4,6 +4,7 @@ use strict;
use Test::More;
use IkiWiki;
+my %ideal_test_plan = (tests => 8);
my $dir;
sub _determine_test_plan {
@@ -19,7 +20,7 @@ sub _determine_test_plan {
}
}
- return (tests => 11);
+ return %ideal_test_plan;
}
sub _startup {
@@ -59,49 +60,77 @@ sub _create_test_repo {
system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
}
-sub test_web_commit {
- my $test1 = readfile("t/test1.mdwn");
- writefile('test1.mdwn', $config{srcdir}, $test1);
+sub test_web_add_and_commit {
+ writefile('test1.mdwn', $config{srcdir}, readfile("t/test1.mdwn"));
IkiWiki::rcs_add("test1.mdwn");
+ my $message = "Added the first page";
IkiWiki::rcs_commit(
file => "test1.mdwn",
- message => "Added the first page",
+ message => $message,
token => "moo",
);
my @changes = IkiWiki::rcs_recentchanges(3);
-
- is($#changes, 0);
- is($changes[0]{message}[0]{"line"}, "Added the first page");
- is($changes[0]{pages}[0]{"page"}, "test1");
+ is(
+ $#changes,
+ 0,
+ q{1 total commit},
+ );
+ is(
+ $changes[0]{message}[0]{"line"},
+ $message,
+ q{first line of most recent commit message matches},
+ );
+ is(
+ $changes[0]{pages}[0]{"page"},
+ "test1",
+ q{first pagename from most recent commit matches},
+ );
}
-sub test_manual_commit {
- my $message = "Added the second page";
-
- my $test2 = readfile("t/test2.mdwn");
- writefile('test2.mdwn', $config{srcdir}, $test2);
+sub test_manual_add_and_commit {
+ writefile('test2.mdwn', $config{srcdir}, readfile("t/test2.mdwn"));
system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
+ my $message = "Added the second page";
system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
my @changes = IkiWiki::rcs_recentchanges(3);
- is($#changes, 1);
- is($changes[0]{message}[0]{"line"}, $message);
- is($changes[0]{pages}[0]{"page"}, "test2");
- is($changes[1]{pages}[0]{"page"}, "test1");
+ is(
+ $#changes,
+ 1,
+ q{2 total commits},
+ );
+ is(
+ $changes[0]{message}[0]{"line"},
+ $message,
+ q{first line of most recent commit message matches},
+ );
+ is(
+ $changes[0]{pages}[0]{"page"},
+ "test2",
+ q{first pagename from most recent commit matches},
+ );
+ is(
+ $changes[1]{pages}[0]{"page"},
+ "test1",
+ q{first pagename from second-most-recent commit matches},
+ );
+}
- # extra slashes in the path shouldn't break things
+sub test_extra_path_slashes {
+ my $initial_cvspath = $config{cvspath};
$config{cvspath} = "/ikiwiki//";
IkiWiki::checkconfig();
- @changes = IkiWiki::rcs_recentchanges(3);
- is($#changes, 1);
- is($changes[0]{message}[0]{"line"}, $message);
- is($changes[0]{pages}[0]{"page"}, "test2");
- is($changes[1]{pages}[0]{"page"}, "test1");
+ is(
+ $config{cvspath},
+ $initial_cvspath,
+ q{rcs_recentchanges assumes checkconfig sanitizes cvspath},
+ );
}
plan(_determine_test_plan());
_startup();
-test_web_commit();
-test_manual_commit();
+test_web_add_and_commit();
+test_manual_add_and_commit();
+test_extra_path_slashes();
_shutdown();