6 $dir = "/tmp/ikiwiki-test-bzr.$$";
11 use Test::More skip_all => "bzr not available"
18 use Test::More tests => 17;
20 BEGIN { use_ok("IkiWiki"); }
22 %config=IkiWiki::defaultconfig();
24 $config{srcdir} = "$dir/repo";
25 IkiWiki::loadplugins();
26 IkiWiki::checkconfig();
28 system "bzr init $config{srcdir}";
31 my $session=CGI::Session->new;
32 $session->param("name", "Joe User");
35 my $test1 = readfile("t/test1.mdwn");
36 writefile('test1.mdwn', $config{srcdir}, $test1);
37 IkiWiki::rcs_add("test1.mdwn");
40 message => "Added the first page",
45 @changes = IkiWiki::rcs_recentchanges(3);
48 is($changes[0]{message}[0]{"line"}, "Added the first page");
49 is($changes[0]{pages}[0]{"page"}, "test1");
50 is($changes[0]{user}, "Joe User");
53 my $username = "Foo Bar";
54 my $user = "$username <foo.bar\@example.com>";
55 my $message = "Added the second page";
57 my $test2 = readfile("t/test2.mdwn");
58 writefile('test2.mdwn', $config{srcdir}, $test2);
59 system "bzr add --quiet $config{srcdir}/test2.mdwn";
60 system "bzr commit --quiet --author \"$user\" -m \"$message\" $config{srcdir}";
62 @changes = IkiWiki::rcs_recentchanges(3);
65 is($changes[0]{message}[0]{"line"}, $message);
66 is($changes[0]{user}, $username);
67 is($changes[0]{pages}[0]{"page"}, "test2");
69 is($changes[1]{pages}[0]{"page"}, "test1");
71 my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
72 ok($ctime >= time() - 20);
74 my $mtime = IkiWiki::rcs_getmtime("test2.mdwn");
75 ok($mtime >= time() - 20);
77 writefile('test3.mdwn', $config{srcdir}, $test1);
78 IkiWiki::rcs_add("test3.mdwn");
79 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
80 IkiWiki::rcs_commit_staged(
81 message => "Added the 4th page",
85 @changes = IkiWiki::rcs_recentchanges(4);
88 is($changes[0]{pages}[0]{"page"}, "test4");
90 ok(mkdir($config{srcdir}."/newdir"));
91 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
92 IkiWiki::rcs_commit_staged(
93 message => "Added the 5th page",
97 @changes = IkiWiki::rcs_recentchanges(4);
100 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
102 IkiWiki::rcs_remove("newdir/test5.mdwn");
103 IkiWiki::rcs_commit_staged(
104 message => "Remove the 5th page",
108 system "rm -rf $dir";