6 $dir = "/tmp/ikiwiki-test-bzr.$$";
9 if (! -x $bzr || ! mkdir($dir)) {
11 use Test::More skip_all => "bzr not available or could not make test dir"
15 use Test::More tests => 16;
17 BEGIN { use_ok("IkiWiki"); }
19 %config=IkiWiki::defaultconfig();
21 $config{srcdir} = "$dir/repo";
22 IkiWiki::checkconfig();
24 system "bzr init $config{srcdir}";
27 my $test1 = readfile("t/test1.mdwn");
28 writefile('test1.mdwn', $config{srcdir}, $test1);
29 IkiWiki::rcs_add("test1.mdwn");
30 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo", "Joe User");
33 @changes = IkiWiki::rcs_recentchanges(3);
36 is($changes[0]{message}[0]{"line"}, "Added the first page");
37 is($changes[0]{pages}[0]{"page"}, "test1.mdwn");
38 is($changes[0]{user}, "Joe User");
41 my $username = "Foo Bar";
42 my $user = "$username <foo.bar\@example.com>";
43 my $message = "Added the second page";
45 my $test2 = readfile("t/test2.mdwn");
46 writefile('test2.mdwn', $config{srcdir}, $test2);
47 system "bzr add --quiet $config{srcdir}/test2.mdwn";
48 system "bzr commit --quiet --author \"$user\" -m \"$message\" $config{srcdir}";
50 @changes = IkiWiki::rcs_recentchanges(3);
53 is($changes[0]{message}[0]{"line"}, $message);
54 is($changes[0]{user}, $username);
55 is($changes[0]{pages}[0]{"page"}, "test2.mdwn");
57 is($changes[1]{pages}[0]{"page"}, "test1.mdwn");
59 my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
60 ok($ctime >= time() - 20);
62 writefile('test3.mdwn', $config{srcdir}, $test1);
63 IkiWiki::rcs_add("test3.mdwn");
64 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
65 IkiWiki::rcs_commit_staged("Added the 4th page", "moo", "Joe User");
67 @changes = IkiWiki::rcs_recentchanges(4);
70 is($changes[0]{pages}[0]{"page"}, "test4.mdwn");
72 ok(mkdir($config{srcdir}."/newdir"));
73 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
74 IkiWiki::rcs_commit_staged("Added the 5th page", "moo", "Joe User");
76 @changes = IkiWiki::rcs_recentchanges(4);
79 is($changes[0]{pages}[0]{"page"}, "newdir/test5.mdwn");
81 IkiWiki::rcs_remove("newdir/test5.mdwn");
82 IkiWiki::rcs_commit_staged("Remove the 5th page", "moo", "Joe User");