Extract subs: startup/shutdown, and tests for web and manual commits.
No functional change intended.master
parent
700d39d765
commit
94c1f3bd33
111
t/cvs.t
111
t/cvs.t
|
@ -29,60 +29,77 @@ use Test::More tests => 12;
|
||||||
|
|
||||||
BEGIN { use_ok("IkiWiki"); }
|
BEGIN { use_ok("IkiWiki"); }
|
||||||
|
|
||||||
%config=IkiWiki::defaultconfig();
|
sub _startup {
|
||||||
$config{rcs} = "cvs";
|
_generate_minimal_config();
|
||||||
$config{srcdir} = "$dir/src";
|
_create_test_repo();
|
||||||
$config{cvsrepo} = "$dir/repo";
|
}
|
||||||
$config{cvspath} = "ikiwiki";
|
|
||||||
IkiWiki::loadplugins();
|
|
||||||
IkiWiki::checkconfig();
|
|
||||||
|
|
||||||
my $cvsrepo = "$dir/repo";
|
sub _shutdown {
|
||||||
|
system "rm -rf $dir";
|
||||||
|
}
|
||||||
|
|
||||||
system "cvs -d $cvsrepo init >/dev/null";
|
sub _generate_minimal_config {
|
||||||
system "mkdir $dir/ikiwiki >/dev/null";
|
%config=IkiWiki::defaultconfig();
|
||||||
system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
|
$config{rcs} = "cvs";
|
||||||
system "rm -rf $dir/ikiwiki >/dev/null";
|
$config{srcdir} = "$dir/src";
|
||||||
system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
|
$config{cvsrepo} = "$dir/repo";
|
||||||
|
$config{cvspath} = "ikiwiki";
|
||||||
|
IkiWiki::loadplugins();
|
||||||
|
IkiWiki::checkconfig();
|
||||||
|
}
|
||||||
|
|
||||||
# Web commit
|
sub _create_test_repo {
|
||||||
my $test1 = readfile("t/test1.mdwn");
|
my $cvsrepo = "$dir/repo";
|
||||||
writefile('test1.mdwn', $config{srcdir}, $test1);
|
|
||||||
IkiWiki::rcs_add("test1.mdwn");
|
|
||||||
IkiWiki::rcs_commit(
|
|
||||||
files => "test1.mdwn",
|
|
||||||
message => "Added the first page",
|
|
||||||
token => "moo"
|
|
||||||
);
|
|
||||||
|
|
||||||
my @changes;
|
system "cvs -d $cvsrepo init >/dev/null";
|
||||||
@changes = IkiWiki::rcs_recentchanges(3);
|
system "mkdir $dir/ikiwiki >/dev/null";
|
||||||
|
system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
|
||||||
|
system "rm -rf $dir/ikiwiki >/dev/null";
|
||||||
|
system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
|
||||||
|
}
|
||||||
|
|
||||||
is($#changes, 0);
|
sub test_web_commit {
|
||||||
is($changes[0]{message}[0]{"line"}, "Added the first page");
|
my $test1 = readfile("t/test1.mdwn");
|
||||||
is($changes[0]{pages}[0]{"page"}, "test1");
|
writefile('test1.mdwn', $config{srcdir}, $test1);
|
||||||
|
IkiWiki::rcs_add("test1.mdwn");
|
||||||
|
IkiWiki::rcs_commit(
|
||||||
|
files => "test1.mdwn",
|
||||||
|
message => "Added the first page",
|
||||||
|
token => "moo"
|
||||||
|
);
|
||||||
|
|
||||||
# Manual commit
|
my @changes = IkiWiki::rcs_recentchanges(3);
|
||||||
my $message = "Added the second page";
|
|
||||||
|
|
||||||
my $test2 = readfile("t/test2.mdwn");
|
is($#changes, 0);
|
||||||
writefile('test2.mdwn', $config{srcdir}, $test2);
|
is($changes[0]{message}[0]{"line"}, "Added the first page");
|
||||||
system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
|
is($changes[0]{pages}[0]{"page"}, "test1");
|
||||||
system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
|
}
|
||||||
|
|
||||||
@changes = IkiWiki::rcs_recentchanges(3);
|
sub test_manual_commit {
|
||||||
is($#changes, 1);
|
my $message = "Added the second page";
|
||||||
is($changes[0]{message}[0]{"line"}, $message);
|
|
||||||
is($changes[0]{pages}[0]{"page"}, "test2");
|
|
||||||
is($changes[1]{pages}[0]{"page"}, "test1");
|
|
||||||
|
|
||||||
# extra slashes in the path shouldn't break things
|
my $test2 = readfile("t/test2.mdwn");
|
||||||
$config{cvspath} = "/ikiwiki//";
|
writefile('test2.mdwn', $config{srcdir}, $test2);
|
||||||
IkiWiki::checkconfig();
|
system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
|
||||||
@changes = IkiWiki::rcs_recentchanges(3);
|
system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
|
||||||
is($#changes, 1);
|
|
||||||
is($changes[0]{message}[0]{"line"}, $message);
|
|
||||||
is($changes[0]{pages}[0]{"page"}, "test2");
|
|
||||||
is($changes[1]{pages}[0]{"page"}, "test1");
|
|
||||||
|
|
||||||
system "rm -rf $dir";
|
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");
|
||||||
|
|
||||||
|
# extra slashes in the path shouldn't break things
|
||||||
|
$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");
|
||||||
|
}
|
||||||
|
|
||||||
|
_startup();
|
||||||
|
test_web_commit();
|
||||||
|
test_manual_commit();
|
||||||
|
_shutdown();
|
||||||
|
|
Loading…
Reference in New Issue