]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/svn.t
web commit by http://madduck.myopenid.com/: poll vote (It's fast enough)
[git.ikiwiki.info.git] / t / svn.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 my $dir;
5 BEGIN {
6         $dir="/tmp/ikiwiki-test-svn.$$";
7         my $svn=`which svn`;
8         chomp $svn;
9         my $svnadmin=`which svnadmin`;
10         chomp $svnadmin;
11         if (! -x $svn || ! -x $svnadmin || ! mkdir($dir)) {
12                 eval q{
13                         use Test::More skip_all => "svn not available or could not make test dir"
14                 }
15         }
16 }
17 use Test::More tests => 12;
19 BEGIN { use_ok("IkiWiki"); }
21 %config=IkiWiki::defaultconfig();
22 $config{rcs} = "svn";
23 $config{srcdir} = "$dir/src";
24 $config{svnrepo} = "$dir/repo";
25 $config{svnpath} = "trunk";
26 IkiWiki::checkconfig();
28 system "svnadmin create $config{svnrepo} >/dev/null";
29 system "svn mkdir file://$config{svnrepo}/trunk -m add >/dev/null";
30 system "svn co file://$config{svnrepo}/trunk $config{srcdir} >/dev/null";
32 # Web commit
33 my $test1 = readfile("t/test1.mdwn");
34 writefile('test1.mdwn', $config{srcdir}, $test1);
35 IkiWiki::rcs_add("test1.mdwn");
36 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
38 my @changes;
39 @changes = IkiWiki::rcs_recentchanges(3);
41 is($#changes, 0);
42 is($changes[0]{message}[0]{"line"}, "Added the first page");
43 is($changes[0]{pages}[0]{"page"}, "test1.mdwn");
44         
45 # Manual commit
46 my $message = "Added the second page";
48 my $test2 = readfile("t/test2.mdwn");
49 writefile('test2.mdwn', $config{srcdir}, $test2);
50 system "svn add $config{srcdir}/test2.mdwn >/dev/null";
51 system "svn commit $config{srcdir}/test2.mdwn -m \"$message\" >/dev/null";
53 @changes = IkiWiki::rcs_recentchanges(3);
54 is($#changes, 1);
55 is($changes[0]{message}[0]{"line"}, $message);
56 is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
57 is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
59 # extra slashes in the path shouldn't break things
60 $config{svnpath} = "/trunk//";
61 IkiWiki::checkconfig();
62 @changes = IkiWiki::rcs_recentchanges(3);
63 is($#changes, 1);
64 is($changes[0]{message}[0]{"line"}, $message);
65 is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
66 is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
68 system "rm -rf $dir";