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();
29 # This is a workaround for bzr's new requirement that bzr whoami be run
30 # before committing. This makes the test suite work with an unconfigured
31 # bzr, but ignores the need to have a properly configured bzr before
32 # using ikiwiki with bzr.
34 system 'bzr whoami test@example.com';
36 system "bzr init $config{srcdir}";
39 my $session=CGI::Session->new;
40 $session->param("name", "Joe User");
43 my $test1 = readfile("t/test1.mdwn");
44 writefile('test1.mdwn', $config{srcdir}, $test1);
45 IkiWiki::rcs_add("test1.mdwn");
48 message => "Added the first page",
53 @changes = IkiWiki::rcs_recentchanges(3);
56 is($changes[0]{message}[0]{"line"}, "Added the first page");
57 is($changes[0]{pages}[0]{"page"}, "test1");
58 is($changes[0]{user}, "Joe User");
61 my $username = "Foo Bar";
62 my $user = "$username <foo.bar\@example.com>";
63 my $message = "Added the second page";
65 my $test2 = readfile("t/test2.mdwn");
66 writefile('test2.mdwn', $config{srcdir}, $test2);
67 system "bzr add --quiet $config{srcdir}/test2.mdwn";
68 system "bzr commit --quiet --author \"$user\" -m \"$message\" $config{srcdir}";
70 @changes = IkiWiki::rcs_recentchanges(3);
73 is($changes[0]{message}[0]{"line"}, $message);
74 is($changes[0]{user}, $username);
75 is($changes[0]{pages}[0]{"page"}, "test2");
77 is($changes[1]{pages}[0]{"page"}, "test1");
79 my $ctime = IkiWiki::rcs_getctime("test2.mdwn");
80 ok($ctime >= time() - 20);
82 my $mtime = IkiWiki::rcs_getmtime("test2.mdwn");
83 ok($mtime >= time() - 20);
85 writefile('test3.mdwn', $config{srcdir}, $test1);
86 IkiWiki::rcs_add("test3.mdwn");
87 IkiWiki::rcs_rename("test3.mdwn", "test4.mdwn");
88 IkiWiki::rcs_commit_staged(
89 message => "Added the 4th page",
93 @changes = IkiWiki::rcs_recentchanges(4);
96 is($changes[0]{pages}[0]{"page"}, "test4");
98 ok(mkdir($config{srcdir}."/newdir"));
99 IkiWiki::rcs_rename("test4.mdwn", "newdir/test5.mdwn");
100 IkiWiki::rcs_commit_staged(
101 message => "Added the 5th page",
105 @changes = IkiWiki::rcs_recentchanges(4);
108 is($changes[0]{pages}[0]{"page"}, "newdir/test5");
110 IkiWiki::rcs_remove("newdir/test5.mdwn");
111 IkiWiki::rcs_commit_staged(
112 message => "Remove the 5th page",
116 system "rm -rf $dir";